SICP - Modularity

- Local state + assignment: Hide time varying behaviour from the rest of the system => modularity

- Two usages of assignment:
  • Permanent local state: e.g. bank account.
  • Temporary local state: scoped by a function execution; e.g. generate unifiorm random numbers (generate Next based on outcome of previous experiment)
- For Temporary local state, if no assignment, the state will be manipulated explicitly by passing additional parameters to other parts of the system ==> leaky system (no modular).

- Programming without any use of assignments (more generally, side effects) is known as functional programming. In contrast, programming that makes extensive use of assignment is known as imperative programming.

- OOP: Is an attempt to model real-world phenomena:
  • Real-world objects are modelled by computational objects with local state. 
  • Time variation in the real world are modelled by state assignment.
- Assignment is used to model system state. An alternative approach to model state is called Streams. The question of which modeling technique leads to more modular and more easily maintained systems remains open

- Stream processing lets us model systems that have state without ever using assignment or mutable data.

- For any "syntactically equals" expressions E1 & E2, the language is said to be referentially transparent if E1 and E2 can be substituted and the evaluation remains unchanged.

- Encapsulation reflects the general system-design principle known as the hiding principle: providing information access only to those parts of the system that have a "need to know". In contrast, abstraction layering is a general concern to build a system from primitives (low layer) to compound behaviour (top layer) and, thus, controlling complexity.

No comments: