DEV Community

Saras Growth Space
Saras Growth Space

Posted on

LLD Domain Modeling: Why Domain Models Exist (Beyond Classes and Objects)

After learning Object-Oriented Design, most developers believe they are ready for Low-Level Design.

They know:

  • classes
  • objects
  • inheritance
  • composition
  • interfaces
  • dependency injection

And when given a problem, they start creating classes immediately.

Yet many designs still feel wrong.

Why?

Because good systems are not built from classes.

They are built from understanding the business domain.

This is where Domain Modeling begins.


The Limitation of Thinking Only in Classes

Imagine you're asked to design:

  • Uber
  • BookMyShow
  • Amazon Cart
  • Food Delivery System

A beginner often starts like this:

User
Driver
Ride

Movie
Seat
Booking

Cart
Order
Product
Enter fullscreen mode Exit fullscreen mode

Then relationships are added:

User has Cart
Order has Payment
Ride has Driver
Enter fullscreen mode Exit fullscreen mode

Technically, this is object-oriented design.

But something important is still missing.


The Question Classes Cannot Answer

Suppose you have a BookMyShow system.

You create:

Seat
Booking
Show
Enter fullscreen mode Exit fullscreen mode

Looks fine.

Now answer:

  • Can two users book the same seat?
  • What happens if payment fails?
  • Who controls seat locking?
  • When does a seat become available again?

Classes alone don't answer these questions.

Because these are business rules.

And business rules are what actually define the system.


Software Exists to Solve Business Problems

Users do not care about:

  • classes
  • inheritance
  • interfaces

They care about outcomes.

For example:

In BookMyShow:

I should not lose my seat while paying.
Enter fullscreen mode Exit fullscreen mode

In Uber:

A driver should not accept multiple active rides.
Enter fullscreen mode Exit fullscreen mode

In Amazon:

The final order amount should be correct.
Enter fullscreen mode Exit fullscreen mode

These are business expectations.

Domain modeling exists to protect them.


What Is a Domain?

A domain is simply:

the business area your software is trying to solve.

Examples:

Ride Sharing → transportation domain

Food Delivery → delivery domain

Banking → financial domain

E-Commerce → commerce domain

Healthcare → medical domain

Every domain has:

  • terminology
  • rules
  • workflows
  • constraints

Understanding these is more important than creating classes.


What Is Domain Modeling?

Domain Modeling is:

the process of understanding business behavior and representing it correctly in software.

Notice something important.

It is NOT:

the process of creating classes.

Classes come later.

First we understand:

  • business concepts
  • business rules
  • ownership
  • responsibilities
  • lifecycle

Only then do we design structure.


Example: Ride Sharing

Many beginners see:

Rider
Driver
Ride
Enter fullscreen mode Exit fullscreen mode

But domain modeling sees:

Driver availability
Ride lifecycle
Ride assignment rules
Cancellation rules
Fare calculation rules
Enter fullscreen mode Exit fullscreen mode

The focus shifts from:

objects
Enter fullscreen mode Exit fullscreen mode

to:

business behavior
Enter fullscreen mode Exit fullscreen mode

This is a major mindset change.


The Three Things Domain Modeling Cares About

1. Identity

Some things must be tracked over time.

Example:

Order #123
Ride #567
Booking #ABC
Enter fullscreen mode Exit fullscreen mode

These are not just data.

They have identity.


2. Lifecycle

Business objects evolve.

Example:

Order

CREATED
→ PAID
→ SHIPPED
→ DELIVERED
Enter fullscreen mode Exit fullscreen mode

Understanding this lifecycle is often more important than designing the class itself.


3. Business Correctness

Every system has rules that must never break.

Examples:

No double booking

No duplicate payment

No invalid ride completion
Enter fullscreen mode Exit fullscreen mode

Protecting these rules becomes a primary design goal.


Why Domain Modeling Comes After OOD

Object-Oriented Design teaches:

How to structure software
Enter fullscreen mode Exit fullscreen mode

Domain Modeling teaches:

What should be structured
Enter fullscreen mode Exit fullscreen mode

OOD gives tools.

Domain Modeling tells you where and why to use them.

Think of it like this:

OOD = Construction Techniques

Domain Modeling = Understanding the Building Blueprint
Enter fullscreen mode Exit fullscreen mode

Without the blueprint, even excellent construction skills are wasted.


How Strong Engineers Think

Weak approach:

Requirements
→ Classes
→ Methods
→ Code
Enter fullscreen mode Exit fullscreen mode

Strong approach:

Requirements
→ Business Behavior
→ Rules
→ Lifecycle
→ Domain Model
→ Classes
→ Code
Enter fullscreen mode Exit fullscreen mode

Notice that classes appear much later.


Why Domain Modeling Matters in Interviews

Most LLD interview failures happen because candidates focus on:

  • syntax
  • patterns
  • APIs

Interviewers are often evaluating:

  • understanding of the problem
  • ownership of responsibilities
  • business correctness
  • system behavior

Domain modeling directly improves all of these.


What We Will Learn Next

In the upcoming posts we will explore:

  • Entities
  • Value Objects
  • Invariants
  • State Machines
  • Aggregates
  • Bounded Contexts
  • Domain Services

These concepts help transform business behavior into maintainable software.


One-Line Takeaway

Object-Oriented Design teaches you how to build classes. Domain Modeling teaches you what the system actually is before the classes are built.

Top comments (0)