OOP design question
Posted: Thu Jun 21, 2012 6:27 pm
I am working on revamping and recoding a web-based (PHP/MySQL driven) game. In the game, we output text as a variable string.
As an example, you might want to output to the user the phrase "Click here to return to the main menu", so we have a language variable file which has:
Then when we need to output it, we do:
This "worked" for a while. But we've gotten up to around 1400 variables now, and its starting to have some overhead. A page with just 20 strings of text suddenly has 1400 variables(!)
We're pondering storing it in a database, but during that process, it occurs to me that maybe languages need to be an object. A language object, and then english would extend that. I think the language object would only have a getter and a setter (?)
Am I on the right track here, in terms of design, or am I just seeing an object because I'm tired of staring at 30k lines of procedural-only code?
Any discussion would be *deeply* appreciated.
As an example, you might want to output to the user the phrase "Click here to return to the main menu", so we have a language variable file which has:
Code: Select all
$l_return_main = "Click here to return to the main menu";Code: Select all
echo $l_return_main;We're pondering storing it in a database, but during that process, it occurs to me that maybe languages need to be an object. A language object, and then english would extend that. I think the language object would only have a getter and a setter (?)
Am I on the right track here, in terms of design, or am I just seeing an object because I'm tired of staring at 30k lines of procedural-only code?
Any discussion would be *deeply* appreciated.