I'm learning about programming patterns and for our final assignment we were asked to build an "online store".
I was thinking about how to model the User
which can either be Admin
or Customer
.
I thought about the Strategy pattern to model each individual User
with their particular behaviors.
They don't share any behaviors so far, so the Admin
can't addToCart
and Customer
can't registerNewProduct
.
However, they could share behaviors / methods as the system evolves!
Furthermore, the User
won't change it's type in run-time. I.e., once you log in as Customer, you can't log back in as Admin.
Even if they shared behaviors such as seeProductList
, this could be achieved with good ol' inheritance, right?
Should I use Strategy, Inheritance or would you recommend another pattern?
If you need more information, please let me know! :)
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire