In the previous post, we learned that Domain Modeling is not about classes.
It is about understanding:
- business behavior
- business rules
- ownership
- lifecycle
- correctness
Now we begin with the most fundamental building block of any domain model:
Entities
Almost every real system revolves around entities.
Orders.
Bookings.
Rides.
Payments.
Users.
Understanding entities correctly is one of the biggest differences between beginner and strong LLD thinking.
The Simplest Definition
An Entity is:
an object that has a unique identity and must be tracked over time.
The important phrase is:
tracked over time
Because identity is what makes an entity special.
Example: An Order
Imagine an e-commerce system.
A customer places an order.
Order #123
Today:
CREATED
Tomorrow:
PAID
Later:
SHIPPED
Then:
DELIVERED
Notice something important.
Many attributes changed:
- status
- shipment information
- timestamps
But it is still:
Order #123
The identity remains the same.
That is why Order is an Entity.
Identity Is More Important Than Data
Beginners often focus on fields:
Order {
id
amount
status
}
But entities are not defined by fields.
They are defined by identity.
Even if all fields change:
Amount changes
Status changes
Address changes
The business still considers it the same Order.
Identity survives change.
Real-Life Analogy
Think about a person.
You may change:
- hairstyle
- phone number
- address
- job
But you remain the same individual.
Why?
Because your identity is independent of those attributes.
Entities behave similarly.
Entity = Continuity Through Time
This is one of the most important mental models.
Entities represent:
continuity through change.
Example:
Ride Sharing System
Ride #567
Initially:
REQUESTED
Then:
DRIVER_ASSIGNED
Then:
IN_PROGRESS
Then:
COMPLETED
The ride evolves.
But it remains the same ride.
That continuity is what makes it an entity.
How to Identify Entities
Ask this question:
Does the business care about this object's identity?
If yes, it is probably an entity.
Examples:
User
Business tracks specific user.
Entity.
Order
Business tracks specific order.
Entity.
Booking
Business tracks specific booking.
Entity.
Ride
Business tracks specific ride.
Entity.
Payment
Business tracks specific payment.
Entity.
Another Important Question
Ask:
If two objects contain exactly the same data, are they still different?
Example:
Order #101
Amount: ₹500
Order #102
Amount: ₹500
Same amount.
Same fields.
Still different orders.
Therefore:
Entity.
Entity Lifecycle Matters
Entities rarely stay static.
They evolve.
Example:
Booking
CREATED
→ CONFIRMED
→ CANCELLED
Order
CREATED
→ PAID
→ SHIPPED
→ DELIVERED
Ride
REQUESTED
→ ASSIGNED
→ STARTED
→ COMPLETED
This lifecycle is often more important than the fields themselves.
Entities Protect Business Meaning
Consider a banking system.
Account balance changes constantly.
₹10,000
₹15,000
₹8,000
₹25,000
The amount changes.
But the account remains the same account.
The business tracks:
Account #A123
not merely its current balance.
Identity carries business meaning.
Common Beginner Mistake
Many developers think:
Every noun becomes an entity.
Wrong.
Example:
Address
Money
Coordinates
Distance
These are important.
But the business usually does not track their identity.
They describe something else.
These often become Value Objects.
We will cover them in the next post.
Entity Responsibilities
A strong entity is not merely a data holder.
Bad design:
Order {
id
status
amount
}
Good design:
Order {
pay()
cancel()
ship()
}
Why?
Because the entity owns its lifecycle.
Business rules should stay close to the entity whenever possible.
Weak LLD Thinking
Entity = Database Row
Strong LLD Thinking
Entity = Business Object With Identity and Lifecycle
This small mindset shift changes the quality of your design dramatically.
Examples of Entities Across Systems
Ride Sharing
- Rider
- Driver
- Ride
BookMyShow
- Show
- Booking
E-Commerce
- User
- Cart
- Order
Banking
- Customer
- Account
- Transaction
Food Delivery
- Order
- Restaurant
- Delivery Partner
All of them have one thing in common:
the business cares about who they are, not just what data they contain.
The Most Important Insight
Fields can change.
State can change.
Behavior can change.
But identity remains.
That identity is what turns an ordinary object into an Entity.
And once you start recognizing entities correctly, domain models become much easier to design.
One-Line Takeaway
An Entity is a business object whose identity matters more than its current data, allowing it to be tracked consistently throughout its lifecycle.
Top comments (0)