Yorian Posted May 15, 2009 Share Posted May 15, 2009 Dear phpfreaks guru's, This site has some great tutorials about OOP, I've read them all and I finally start to understand how OOP is to be used. I used to create classes which used to handle everything concerning the subject, from the output to all the logic. If we take the user class, this would create all the forms, check all the input etc. A bit later I seperated the view from the "business logic" in my mvc, which created to classes the user view and the user controller which also held all the data and the logic. However having read the articles about OOP and especially the part about Seperation of concerns I now see that I have to split up my classes even further. My question: How would I set up a member system with roles (such as admin, etc.) and how would I create a loose dependency (avoid tight coupling)? Here's what I've got so far: - user_controller class (the controller) - user class (contains the user data) - user_factory class (creates the user object) - user_manager class (does the adding, deletin, updating etc. of the DB) - user_html_view (handles the html output) - user_mail_view (handles the output used in sending the mails) - a couple of interfaces and abstract classes to make sure things work as they expected However I still feel there is missing quite a bit: I want to be able to use mysql or pgsql depending on a certain config setting which is set. Therefor I will have the need for two different classes with the sql statements one for pgsql queries and one for mysql. There are some functions of which I do not know where to put them, so maybe you guys can give me a good idea on how to build a member system. Next ofcourse is how to build a roles system and how to avoid coupling the to "modules" tightly. And where to put the functions such as get_user_roles(), etc. Can anybody help me out and show me a good start on which classes to build containg which methods? Link to comment https://forums.phpfreaks.com/topic/158326-oop-user-system/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.