What is domain logic?

ArchitectureTerminologyBusiness Logic

Architecture Problem Overview


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?

Architecture Solutions


Solution 1 - Architecture

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.

Solution 2 - Architecture

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!

Solution 3 - Architecture

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)

Solution 4 - Architecture

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.

Solution 5 - Architecture

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).

Solution 6 - Architecture

Business logic specific to one particular field/area of expertise.

Solution 7 - Architecture

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.

Solution 8 - Architecture

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".

Solution 9 - Architecture

  • 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).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSydiusView Question on Stackoverflow
Solution 1 - ArchitecturejakberView Answer on Stackoverflow
Solution 2 - ArchitectureAgile NoobView Answer on Stackoverflow
Solution 3 - ArchitectureVLostBoyView Answer on Stackoverflow
Solution 4 - Architecturepalash140View Answer on Stackoverflow
Solution 5 - ArchitecturemfxView Answer on Stackoverflow
Solution 6 - ArchitectureBrian KnoblauchView Answer on Stackoverflow
Solution 7 - Architecture5x1llzView Answer on Stackoverflow
Solution 8 - ArchitectureMike DunlaveyView Answer on Stackoverflow
Solution 9 - ArchitectureAaronView Answer on Stackoverflow