I am still trying to wrap my head around design patterns and for the second time I'm coming up against the same problem that seems to be crying out for a pattern solution.
I have an accounts system with multiple account types. We have restaurant, hotel, service_provider, and consumer account types. Im sure there will be more business account types in the future, and of course there's a global administrator account.
So what I'm wondering is how to implement the switching of account types. Eg. each account will have one or more profiles, but the profile will be different depending on the account type. What kind class relationships should I use here to deal with the multiple types of account - polymorphism or inheritance?
It seems like maybe there should be an abstract base Profile class that the other profiles should extend, but I'm not sure how to implement that (eg a join table between profile types and account types?).
It also feels like an opportunity to implement the factory pattern, I'm just not sure really how to go about it.
Any ideas please?
*
*
Edited to provide some examples as suggested:
Account -> hasMany -> Users
Account -> belongsTo -> AccountType
Account -> hasOne -> Profile
The profile is different depending on what type of account it is, eg an account of type restaurant will have a menu, a wine list etc, an account of type hotel will have room types, amenities, an account of type consumer will have personal tastes, home country etc.
The question was what design pattern would best implement these relationships.
Hope thats clearer, thanks!