Should models have business logic?

Should models have business logic?

The application logic (interaction between domain logic structures and storage abstraction) should be a part of model layer. To be more precise: it should be inside the Services . The interaction between presentation layer (models, views, layouts, templates) and model layer should happen only through those services.

How do you create a business layer?

Designing Business Logic Layer: Some Guidelines

  1. We try to mix business rules of different modules wishfully.
  2. Writing methods with abundant codes.
  3. Not clearly separating responsibilities of presentation and data access layers.
  4. Creating code duplicity, i.e.; writing same set of code or methods at various places.

What is the difference between service layer and Business Layer?

The Service Layer is usually constructed in terms of discrete operations that have to be supported for a client. For example, a Service Layer may expose Creating an Account. Whereas the Business Layer may consist of validating the parameters needed in creating an account, constructing data objects to be persisted, etc.

How many components does Business Layer consist of?

In the Business Layer, three types of internal active structure element are defined: business actor, business role, and business collaboration.

Can domain services use repositories?

Yes, a domain service can access repositories.

What does Eric Evans say about Domain Driven Design?

Eric Evans’s excellent book Domain Driven Design says the following about the domain model layer and the application layer. Domain Model Layer: Responsible for representing concepts of the business, information about the business situation, and business rules.

Can a domain entity derive from a base class?

Domain entities should not have any direct dependency (like deriving from a base class) on any data access infrastructure framework like Entity Framework or NHibernate. Ideally, your domain entities should not derive from or implement any type defined in any infrastructure framework.

How does DDD help you understand the complexity in the domain?

DDD patterns help you understand the complexity in the domain. For the domain model for each Bounded Context, you identify and define the entities, value objects, and aggregates that model your domain. You build and refine a domain model that is contained within a boundary that defines your context.

How does the domain model layer depend on infrastructure?

Most of all, the domain model layer must not directly depend on any infrastructure framework. The infrastructure layer is how the data that is initially held in domain entities (in memory) is persisted in databases or another persistent store.