Notice that, in general, we have to distinguish between real-world objects (or business objects) and OOP objects (such as JS objects or Java objects). A string may be an OOP object (e.g., in Java), but it's not a business object.
In Java, or, more specifically, in Java EE, an entity is a special Java object that instantiates a Java entity class, which is a Java class that is JPA-annotated as @Entity
such that all its instances are automatically saved to persistent storage in a Java EE environment (such as TomEE).
A Java entity is intended to represent a business object. A Java string object cannot be a Java entity.
Any (business or OOP) object has it's own (local) state, and can also acces the state of other objects to which it is linked by means of references (via associations).
The question is: which business object types from a domain model (such as player, prediction, option, coin, coin game) have to be included as OOP classes in an OO design model? We can also say that the design model is derived from the domain model, which is obtained from the requirements.
Both domain models and design models can be made in the form of UML class models (visualized as class diagrams), see also this SO answer. A domain model describes a real-world domain, while an OO design model defines OOP classes to be implemented with a specific OOP language (like Java).
The selection of classes from the domain model to be included in the design model depends on the information requirements of your app development project. You have to identify what is the relevant information to be captured with your model (and the resulting Java classes).
If the purpose of your app is to record and display information about your coin flipping games, then I would include the following classes in a design model:
- Player( id, name)
- Game( id, date-time, bettingPlayer, opponent, bet, outcome)
Here, bettingPlayer
and opponent
would be reference properties, which represent corresponding associations between Game
and Player
.
Making such a design from a domain model requires some experience in identifying the relevant information items. Transforming a business domain model into a
platform-independent system design model involves both simplification and elaboration.
The domain model is simplified by
- abstracting away from elements that only have business meaning but no informational/computational meaning for the system to be built;
- compressing certain parts of the model to get a more efficient design (a business domain model is more concerned with conceptual explicitness while a system design model is more concerned with efficiency)
The domain model is elaborated by adding details, which are essential for the design (such as standard identifiers, data types, etc.).
Here is a (not quite up-to-date) tutorial that may provide some help.
And here is a diagram illustrating the model-based development process:
