I am currently rewriting an electronic store, but only the client side, i.e. CMS remains mostly tactful. I do not use a pre-built structure, since the system must maintain backward compatibility with CMS, and I must have complete freedom of the code structure.
The new system is based only on MVC, and I have a Bootstrapper that loads controllers based on the current uri, and the latter use models for real work - both with sessions and with the database.
tl; dr This is my first project without a predefined structure.
I am very inexperienced when it comes to design patterns. I know how most of the popular ones work, but have never used them.
Now I suspect the code smells because all my models are classes that consist solely of static methods. I do not see any advantages in doing them differently. I usually need some methods in different places through the code. That is, I need to get a registered user in the main layout, check the user rights to see the current page in the bootstrapper, and display the user panel with the controller. I would need to re-create the object each time or save the global one if I hadn't used statics. There will also be no need for more than one such class at a time.
Something is missing me, because although I use OOP, some of my classes are just meaningless containers for their methods (and sometimes a couple of private variables). I could just use PHP4 and simple functions.
Any comments or recommendations would be highly appreciated.
EDIT: Despite all these educated answers, I remain unconvinced. Despite the fact that, most likely, due to my lack of experience, I still do not foresee that something is wrong with the current setting. I mean, I don’t even understand the situation when I would have inconvenience due to the code architecture, as it is now. I hope I don’t get a harsh lesson when it’s too late to change anything ...
php design-patterns static-methods
raveren Mar 09 '10 at 16:23 2010-03-09 16:23
source share