Assumption:
We have to create REST layer for managing users.
The natural thing for us is to create two methods:
for creating an user (or register a user)
for obtaining the user.
We start from the first one and firstly focus on defining user model: first name, last name, age, country, language, etc.
So far so good. The next thing is method for obtaining the user details: first name, last name, age, country, language AND additionally the whole box of other values that have been set up during user registration: id, default groups that user belongs to, maybe roles (administrator, moderator?), datetime when user had been registered and so on).
We would set this information about user within one class (user model) but what about set up constraints to these internal elements? For instance: first name or last name should be required and defined in both cases (create & get), it's ok, but user id? it's not required during 'create user' method (even it's prohibited) but get method should have this field.
It seems the simplest way is to split the user model into two classes: UserBase with all required fields (for registration) and User extends UserBase for other cases.
It's just a requirement for well implemented REST services based on resources: create new resource (user): POST ../users obtain resource (user): GET ../users/{id}
What is the best practise to handle this problem?