Skip to content
DMXRoid edited this page Jan 21, 2011 · 1 revision

There seems to be a lot of code that could probably be replaced with a set of eval() calls, especially in the factories where get methods are just used to instantiate a class in the format of . Why not do that, and cut down on both code and manual intervention?

It would save some code and some time, but there are a few reasons for not doing it that way.

  1. eval() is the fucking devil, and people who use it should be kicked in the dick until they sneeze blood. Out of all the really stupid, awful things that bad developers can do with PHP, and there are a lot of them, eval() calls are worst. Worse than register_globals. eval() is never the right goddamn solution to the problem. Don't write code that executes code. Write code that does shit. If you think you need to use eval, you're thinking about the problem wrong.
  2. Using eval()'s in place of case statements inside the various factories would decrease flexibility in the framework. There are innumerable circumstances where you might want a different object returned than the one indiciated by the combo, and using eval()'s would make it more complicated to account for those circumstances.
  3. The patterns in the Generic* objects do a lot to make it much easier to get a rendering webpage going. All you need for a page is a mainbody_<page_name>.comp.php file, you don't have to add things to, say, PageFactory or LinkFactory to get related Page or Link objects, because the Generic versions of those work pretty well in most basic cases. The argument isn't that overhead is eliminated, but that it's mitigated.

Clone this wiki locally