php - OOP design approach for two interacting classes -
Relative advantages / disadvantages by using classes (or rather; Are compared to nesting classes?
I am trying to reconstitute my user / authentication system and I am surprised;
- MyAuthClass should act as a utility and if log-in is successful, just create a new myUserClass object
- or myAuthClass should internally create myUserClass ( I.e. $ the-> user = new myUserClass)
- Or even if myUserClass should only call myAuthClass when needed (i.e. when a user tries to log in) and its Updates internal structure (new email, favorites, cart, etc.) as needed.
As you can tell that I am able to make a case for each method of appropriately of an OOP N & SB, so I'm about the different ways + I am interested in hearing from others.
Cheers. <3 p>
With an extraordinary perspective, all 3 options are incorrect because they are programmed against solid implementation And not an abstract interface. As they gather together in a joint together, who reuse the reusable limit - whether you use both of them again or not.
You can generate IUserClass, or IAuthClass and apply this abstract interface in a solid range, and then I
allow most flexability in each case In the situation where an IUserClass, or user class was given the implementation of IAuthClass while authenticating to populate the implementation of the auth class. The Auth class can be reused and different versions of UserClass can be generated, or the user has the ability to use many different authentication mechanisms in the class, as long as the heir to IAuthClass.
User class A certification object (which implements IAuthClass) will be my preference, that authentication mechanism varies, even with the same application, when the user class will be reduced but true To be, no solid implementation should be based on.
It can be seen from above, so this is a decision call.
Comments
Post a Comment