vendredi 23 janvier 2015

What design pattern to use to create multiple users in PHP Application?

I have a working web application in PHP that was "messed up" due to the need of fast development. I ended up duplicating the "Sign up" code multiple times due to the demand. Now that I can breathe again, I want to re-organize it all the right way - design pattern. I'm strugling with finding the right one to use.


The Situation


I currently have 4 types of users and we predict at least 3 more in the future. For now they are:



  1. Administrator (Group of shop Administrator)

  2. Staff (Shop Manager)

  3. Staff (Shop Salesman)

  4. Customer


In a near future, I'll have to allow both staff to be also customer simultaneously. I'll also have support center and reporter.


The Problem


Creation. Creation. Creation. I'm not worried about Access Control, Permission, etc... The code I have now can do wonders in this area. My problem is only about creation. And it seems that Abstract Factory might be the one for me, but the truth is all those "abstract tutorials" teaching Design Pattern using books and cars is just not helping me bring it to my situation. Either I'm at the wrong Design Pattern or I'm not understanding it.


Tl;dr


I just need a little help to understand how I can organize my classes to allow me to create multiple users and allow me in the future to create new types of users. I know how to implement/handle the data and the database in my project, I just need the structure of the classes that can best help me in this situation so I can implement the methods.


Tutorials I read



Aucun commentaire:

Enregistrer un commentaire