Non-Data Classes Part of the Model?

Are non-data classes (which represent nothing in the database) still considered part of the application domain model or not? Would you put them alongside your Linq2Sql domain model or somewhere else?

Edit . Information about the classes. For example, I have a StatusMessage class that is generated under certain circumstances and can be dropped or displayed to the user. It has nothing to do with data from the database (neither search nor storage). Another example is the Invitation class. Users on my site can "invite" each other, and if they do, an invite class is created that encrypts some information and then issues a link that the user can provide to someone else. I have 25 classes. They are not meant to transfer data, they do work, but they are not database related, and I would not say that they are all "helpers"?! ....

+2


source to share


2 answers


It depends.

If these classes are a combination of data coming from different tables, process the data, make decisions, and organize operations, then I would look at their business layer entities and store them in the business layer.

If these are some kind of helpers, it will depend.



ADDED: After reading some more information about these classes, I think many of them deserve a worthy place in your business logic. You might want to draw a line between the domain model and business logic. I assume you think your domain model contains only database mapping classes, which is fine. But then there are also business rules, work classes that accept user input, process it, make decisions, and invoke the necessary operations to make them. They can include CRUDing something into the database, send email notifications, initiate scheduler tasks, notify other services, etc. For many actions, their result will be remotely reflected only in the database, some values ​​can be changed, but not as the complete state of the business object goes directly to the database.Therefore, it would be wise to keep them together in a selected layer.

Another option would be to put the logic of these classes into stored procedures, thereby storing it in the database. What does not fit can be grouped as helpers.

With "StatusMessage" it may not be necessary to have a separate class for this. Messages belong to the presentation layer. The class can simply decide which message to show, but then the actual display work will be closer to the user interface.

+1


source


A domain model is data related to a domain. It can come from any source, it can be one way (for example, calculated and stored only and never read). A database is a strategy to keep only one domain.

So yes, data from different places can be part of the domain model.



Personally, I find a message more like a viewmodel object, whereas a state indicating a requirement for specific messages might be in the domain model. If prompted, I would say that the message goes to the service and thus becomes the domain data that is ultimately passed on, and I assume it is domain data belonging to another user (and is said to be displayed using which -or other presentation model).

+1


source







All Articles