-1

I'm planning a web system where there are mainly two types of users. My project is powered by Play! framework and ebean as the ORM layer.

Now, with the OOP perspective I should create a User Model and then two more classes which extends User. Another way, relatively simple is creating two different models and hence, two different DB tables.

What is the preferable way to choose and why?

Thanks

AngryOliver
  • 397
  • 1
  • 4
  • 18

1 Answers1

1

If something is and always will be a specialization of a generalization then use inheritance.

If something plays the role of something, then use composition.

Example:

An individual person is and always will be a specialization of an abstract legal party.

A person could be a customer one day, an employee the next, a supplier the next. They play those roles. Use composition in that case.

So for your users, are they permanent specializations? Or are they different kind of roles?

Neil McGuigan
  • 46,580
  • 12
  • 123
  • 152