Aggregation
Suppose a bank account is represented by these state variables, e.g.,
// Bank account.
int balance; // current balance
int deposits; // deposits to date
int withdrawals; // withdrawals to date
Shortcomings:
- Understandability: The relationship of the variables to one another is only implicit, not explicit.
- Scalability: If we want to represent two bank accounts, we have to write twice as much:
// Bank account 1.
int balance1; // current balance
int deposits1; // deposits to date
int withdrawals1; // withdrawals to date
// Bank account 2.
int balance2; // current balance
int deposits2; // deposits to date
int withdrawals2; // withdrawals to date