The domain model is a representation of meaningful real-world concepts pertinent to the domain that need to be modeled in software. The concepts include the data involved in the business and rules the business uses in relation to that data. A domain model leverages natural language of the domain.
Domain modeling is a technique used to understand the project problem description and to translate the requirements of that project into software components of a solution. The software components are commonly implemented in an object oriented programming language.
A Domain Model is an Object Model describing the problem domain. They include the domain objects in the problem domain and describe the attributes, behavior and relationships between them.
A domain model (the term is not at all Java specific) is a class that models something in the problem domain, as opposed to a class that exists for technical implementation reasons.
Domain model instances often need to be persisted in a database, and in Java, they typically conform to the Java Beans specification, i.e. they have get and set methods to represent individual properties and a parameterless constructor. Spring and other frameworks allow you to access these properties directly in your JSPs.
For example, in a shop application, some of your domain model classes would be Product, Order, ShoppingCart and Customer.
A Domain model is a conceptual model of the problem domain. By "java domain model" they just mean the java classes representing that model. There's nothing specific to java in the concept.
See also Domain Driven Design for an approach to focusing your development on the business domain needs.
Michael Borgwardt's answer "A domain model (the term is not at all Java specific) is a class" is wrong. I am very surprised so many agree with that answer.
A domain model is all the classes that model the behavior of the solution. It is the minimum necessary to accomplish the required behavior. The domain model is free of UI and persistence functionality (unless the problem revolves around UI or persistence).
I have seen domain model implemented in one class but that is not the design of an object-oriented solution. In an object-oriented domain model, each concept has its own class that implements the behavior required of that concept and contains the necessary fields to maintain the state of the class.
Let’s start with an example. You are creating an application with will be used by some people in your locality. When design the system you call these people users of your system. You also have to manage a list of roles for these people in the system and authentication information. So, you decide to create a conceptual entity in the system. This conceptual entity is further mapped to a User object in you software solution (your application). Now when you represent your application, you describe that User object as a Domain Model. The basic idea behind this term is that only. You can further read about it in the following Wikipedia link.
I know it has been a long time since the last post here. But it is important that information around this concept is clear. A domain model is often a set of classes which represent a particular problem domain. The concept is not tied to any one type of technology implementation. I think it is a little misleading to say :
"Domain model instances often need to be persisted in a database, and in Java, they typically conform to the Java Beans specification, i.e. they have get and set methods to represent individual properties and a parameter-less constructor. Spring and other frameworks allow you to access these properties directly in your JSPs"
Domain models are often the result of domain driven design. Domain driven design is teh key to a good and robust domain model. I suggest having a read through Eric Evans' book Domain Driven Design, to give you a better understanding.
Domain model classes do have information associated to them but behavior in my opinion, is more important than data in this context. A big mistake around domain driven design is to create data classes that represent the data of a domain entity ,such as customer and provide only public getters and setters for the customer attributes. These object tend just to mimic your database structure and as a result the actual business logic is more likely to reside in domain services , resulting in a anemic domain model. This model is closer to a Transaction Script than a domain model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With