This question keeps popping out every time I create a new Solution.
I would like to separate the Request Object, Database Entity and Response Object. If your Web API handles few entities I agree that it is not necessary to separate them. But what if I have the following requirements:
Request Objects (api payload) has:
- FirstName
- LastName
- BirthDate
Database Entities (table) has:
- Id
- FirstName
- LastName
- BirthDate
- CreateDate (for audit)
- CreateBy (for audit)
- UpdateDate (for audit)
- UpdateBy (for audit)
Response Objects (api body) has:
- Id
- FirstName
- LastName
- BirthDate
- Age (calculated, readonly)
(Questions) > so with this idea in mind:
- Does it make sense to create separate classes for each type of objects?
- What naming convention can i use?
- Is there already a best practice to handle this different kind of objects?
- Is it fine to just use the suffixes Request, Entity, Response for each type of objects?
Reply are greatly appreciated!