What is domain logic? The Wikipedia page for domain logic redirects to business logic. Are they the same thing, and, if not, how do they differ?
The domain is what you are modelling.
If you are modelling a business problem, they are the same thing.
If you are modelling something else, physics for instance, there is probably no business logic in your system, but the physics parts are still domain logic.
Domain is the world your application lives in. So if you are working on say a flight reservation system, the application domain would be flight reservations.
Business Logic on the other hand is a more discrete block of the entire Application Domain. Business Logic is usually a section of code built to perform one specific business process. So you would have business logic to take a reservation. Another bit of business logic would be code to refund cancelled tickets.
The objects that support your business process then become your business objects!
Business logic is teleological (concerned with how to achieve an objective) while domain logic is ontological (what exists, or the object model that's used to reason with)
Let's cover a scenario.
You have a client for XYZ restraint and he wants you to make his system online.
Where user can place an order online, track them, make payment etc.
For a client point of view this system would be called Business Idea while "place order online" said to be one of the business process and if user place order online, client wants each detail of user, want to display it on screen etc said to be Business logic.
Now you will model his business idea into your point of view in a way that your system can accomplish his all business process or his complete business idea said to be Problem Domain or Application Domain or Domain of your Application.
Now you will first identify all the business processes. And identify entities or object to accomlish business processes. Those object said to be Business Obect or Domain Object and method or logic that implement business process like placeOrder said to be Domain Logic.
So business logic is what client wants because its in client business domain and domain logic is how you implement it. because it's in your application domain.
Business logic specific to one particular field/area of expertise.
Domain logic applies to the problem domain, e.g. "order processing". Domain logic is about the entities you work with (the object model), and their relationships.
Business logic contains rules specific to your context, e.g. "orders from customers of group X are to be processed using discount Y when exceeding amount Z". Business "logic" is about encoding facts about your business (or the business of the customer who uses the program).
I would say the Business Logic is related to:
Any logic or association between entities in the Domain.
So how does a Student relate to a Class or a Student. How is a new Class created and how do you Register a Student for that Class
Anything to do with business rules, determining outcomes, services, events, processes, calculations, transformation and related data manipulations/creation.
I have found it hard to find good books/teachers to help structure domain logic. It's easy to structure the domain. But domain logic seems to me a place no one wants to go.
My domain is pharmaceutical. It deals in compartments, doses, differential equations, and statistics. If you want to call that my "business", then I guess it's "business logic".
- Business logic is concerned with coordinating valid interactions between view and model (ui and data).
- Domain Logic is about keeping an internally consistent model representation on both sides of the app (client and server).
来源:https://stackoverflow.com/questions/360860/what-is-domain-logic