Primitive Obsession Flashcards

(7 cards)

1
Q

What is the Primitive obsession?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are entities?

A

An object defined primarily by its identity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are value objects?

A

Objects lacking the concept of identity. They are defined and their attributes are immutable. Eg. Math.Pi object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Effects of primitive obsession

A
  1. Resulting code is cluttered and hard to read
  2. 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do entities stay persistent?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Entity Considerations

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between Value objects and entities

A

Value objects and entities are complete opposites, one lacks the concept of identity and the other is defined primarily by the identity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly