Tutorial :Business objects vs. entities


Is there a difference between a business object and an entity?

If I were to define a POCO type of class, say a Product class, would that be a business object or an entity?

public class Product {      public int ID { get; set; }      public string Name { get; set; }      public double Price { get; set; }      public string Sku { get; set; }  }  

Note there is no functionality within this object.


I would call it a DTO (Data Transfer Object). I have also seen them called "Property Classes" in times past. I would NOT call it a Business Object because it has no behavior and by definition BO's are defined by their behavior.


All entities are business objects, but not all business objects are entities.

Entities are business objects whose identity is defined not by their attributes, but by an identifier, like Product's ID.

An example of a business object that is not an entity could be Color. Color derives its identity from its RBG values.

I'm referring to, of course, Entities and Value Objects in Domain-Driven Design.


I consider them the same, although maybe if you have some controller-like classes (which operate on your domain model) in your business layer they might not be called entities. I would say that classes like Product are both business objects and entities, while a ProductController would be only a business object. An entity represents a domain model object - a user, a book, a car, etc., something that contains data of its own as well. I think it's just a matter of naming and is not important, I tend to use both terms interchangeably, but will usually use the "rules" I depicted above.


I don't think there is a clear distinction between business objects and entities. Different practioners seem to use different versions.

See these comments by Ayende.


The term "entity" is normally used as a more pretentious way of saying "thing". Consider entity reationship diagrams for example - diagrams which show the relationship between things.

Buisness objects are simply things (oops, entities) in the business domain. I would say your Product is a buisness entity - compare it with say a String, which is a thing in the implementation domain.


In my experience entities are usually associated with CRUD. Business objects can also be non persistent objects such as strategies, policies etc.


Is there a difference between a business object and an entity?

Wikipedia defines "business object" to be the same as what I call an "entity". The confusion for me with this definition is in the word "business" because "business logic" is orthogonal to entities. An "entity" (DTO, "data entity", etc.) is an object with fields and get/set type methods. It holds the data but contains minimal (if any) logic.

A "business logic" or "business rules" object encapsulates the higher order logic need to work with these entities. It uses the fields from the entities to make decisions and to modify and persist the entities as necessary.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »