Primitive Obsession Flashcards
(7 cards)
What is the Primitive obsession?
The anti pattern in which developers are too focused on using primitive data types like vanilla ints, characters and floats as opposed to well-defined domain specific objects
What are entities?
An object defined primarily by its identity
What are value objects?
Objects lacking the concept of identity. They are defined and their attributes are immutable. Eg. Math.Pi object
Effects of primitive obsession
- Resulting code is cluttered and hard to read
- Can lead to a lack of type safety, no inherent structure or validation with primitive data types (think of the compare or equals overriding methods)
How do entities stay persistent?
The entity object will maintain the identity from its id (think databases)
They have life cycles which can change over time however the id keeps their identity
Entity Considerations
What is the difference between Value objects and entities
Value objects and entities are complete opposites, one lacks the concept of identity and the other is defined primarily by the identity.