15

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.

1
  • According to my own "rules" which I described in my answer - the class you presented would be an entity. Mar 9, 2009 at 13:24

7 Answers 7

14

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.

1
  • 3
    This is contradictory to what Wikipedia says: en.wikipedia.org/wiki/Business_object - "Whereas a program may implement classes, which typically end in objects managing or executing behaviors, a business object usually does nothing itself but holds a set of instance variables or properties" Mar 21, 2013 at 5:39
10

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.

1
  • 1
    I would say that a color is considered a value object. It is identified by its value and multiple instances with the same value are considered to be identical. Usually VOs are also immutable. The color red does not change. Sep 2, 2013 at 21:02
6

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.

1

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

0

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.

0

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.

1
  • I agree with the "entity" description but you mix "business entity" with "business object".
    – Gray
    Apr 28, 2014 at 22:52
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.