chapter two
2 Data, Identity, and Values
This chapter covers
- Identity and change
- Values and Value Objects
- What “Data as Data” means
- Modeling data with Records
This chapter is about how to represent data "as data" in a language where everything is an object. It’s easy once you know the trick, but to get there we first have to dive into what objects are, pick apart how they model time and space, and explore casual metaphysical questions like “what does it mean to be something?”
By the end, we’ll know not just how to model static information “as data,” but how to model complex, real-world entities that grow and change over time.
2.1 Identity is about continuity over time
Identity is state + time. Even something as simple as a variable assignment sets up a deep relationship between the identity of the variable and the states that get stored inside it over time.
Listing 2.1 A relationship between state and time
public static void main(String... args) { |
double xPosition = 4.2; |
|
xPosition++; |(time) #A
xPosition++; | #A
xPosition *= xPosition; ▼ #A
}