0

When I retrieve data from database I name the class as Model, for example UserModel.

When I send data to the View I name the class as ViewModel, for example UserSettingsViewModel.

How to name the class that exchange data between layers?

3
  • Mention few options that you think are correct, but not sure which to choose from. Then the community will know what you are thinking and can help accordingly.
    – Manoj R
    Commented Apr 10, 2017 at 6:46
  • I use DTO or data transfer object for data that travels from business layer to view layer.
    – k3b
    Commented Apr 10, 2017 at 7:06
  • The layer is an adater though.
    – Walfrat
    Commented Apr 10, 2017 at 7:36

2 Answers 2

4

My suggestion is to omit the 'Model' suffix from your main class. I have seen 'DataTransport' or 'DT' classes, but generally you shouldnt need a separate class for this.

example classes

  • Database Table : User
  • read into : DataReader (from db client)
  • which populates : User
  • which populates : UserEditingViewModel
  • which binds to : UserEditingView

or in an api where you send data over the wire

  • Database Table : User
  • read into : DataReader
  • which populates : User
  • which is serialised to : string (json/xml)
  • which is deserialised to : User
1
  • How I can learn more about these things? I have read Code Complete but this book is very old and I would like to find something similar for today technology, mostly for web. Commented Apr 11, 2017 at 4:45
0

A Gateway suffix is also used, for example DataAccessGateway between the DAL and the business logic layer is responsible to convert the data to a model object that is received by the business logic that works with a model of the data

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.