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?

  • 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 Apr 10 '17 at 6:46
  • I use DTO or data transfer object for data that travels from business layer to view layer. – k3b Apr 10 '17 at 7:06
  • The layer is an adater though. – Walfrat Apr 10 '17 at 7:36
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
  • 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. – Menelaos Vergis Apr 11 '17 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, privacy policy and cookie policy

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