Differencs Between Domain Logic and Business Logic

GongBaek·2025년 7월 15일

Introduction

When we're studying Android Development, we often run into terms like domain, domain layer, domain logic, and business logic.

We've heard them a lot, but when it comes to actually explaining them, they can get annoyingly confusing.

Let's make it simple.


What Is a Domain?

A domain is the main topic or area your app is about.
It’s the part of the real world your app is trying to help with.

For example:
• In a shopping app: products, cart, orders, payments
• In a weather app: location, weather info, forecast, alerts

So in short, the domain is why your app exists.


What Does the Domain Layer Do?

In clean architecture, the domain layer handles the core logic of your app.
It does not care about how things look (UI), or where the data comes from (network, database).

Here’s the key point:

The domain layer focuses on what your app should do,
not how it does it or where it gets the data.

You can think of it as the brain of the app.


Domain Logic vs Business Logic

These two are similar, but not exactly the same. Here’s a simple way to look at it:

Term Domain Logic Business Logic
What it is All rules and logic in your domain Real-world rules for the company or product
Scope Bigger Smaller (part of domain logic)
Example “You can’t order an item if it’s out of stock” “Free shipping for VIP customers”

So, business logic is a specific part of domain logic.
It includes the actual rules that match what the business wants.


Example in Android

Let’s say you’re making a shopping app.
• Product, Cart, Order → domain models
• Cart.add(product) → has logic like avoiding duplicates or checking limits (domain logic)
• “Free shipping over $30” → business rule

This kind of logic should not be written in the UI or network code.
Putting it in the domain layer makes it easier to test and reuse later.


Summary

  • The domain is what your app is about.
  • Domain logic is the rules and actions inside that area.
  • Business logic is the actual policies or rules from the company.
  • Keeping this logic in the domain layer helps you build better apps.

You won’t see domain design in the UI,
but it makes your app more stable, easier to manage, and ready to grow.

If you want, I can also add some example code to this post. Just let me know.

profile
Junior Android Developer

0개의 댓글