Search code examples
umlentityclass-diagramuse-case

What are Entity Value and Service classes means?


I googled and tried many online links to find out the Entity, values and service classes. But nothing found. Can someone explain with a good example that how to find out such classes from a class diagram?
take this ClassDiagram for instance.


Solution

  • Entities, values and services seem to refer to a Domain Driven Design context:

    • an entity is an object which has its own identity, and keeps its identity despite potential modifications of the values in its fields.
    • a value object is an object which has not an own identity. A value object is defined by the value of its fields. Therefore it should in principle be immutable.
    • A service is an operation that is not of the responsibility of an object (entity or value). THe DDD service is not to be confused with a service layer

    In your diagram:

    • all classes have their own ID, which suggest that they are all entities. User_vehicle ssems to have a bad naming. It should be called "Subscription".
    • User and Vehicle seem to be aggregate root, with other entities depending on them. Maintenance and Schedule seem to belong to the Vehicle aggregate. It can be discussed whether User_Vehicle and Reservation would belong to the User aggregate or the Vehicle aggregate.
    • There seem to be no apparent class for value object. A value object would not have an ID that ensures it's identity. However, one could argue that dates are value objects, even if not represented explicitely in the diagram.
    • Maybe I'm too old, but I can recognize no evidence of a service here. All the methods seem to be clearly of the responsibility of the object they belong to. A service could be "Create reservation" or "Start subscribtion": in both cases these go beyond the responsibility of a single object: it would always involve at least two entities.