All programming languages are abstractions to better map the real world problem to computer world.
Some early programming languages chose particular views of the world:
But when step outside of that domain, they become awkward.
OOP is a more general way to abstract the real world. Just like things/objects in the real world have characteristics and actions, objects in OOP have states and performe operations. When reading the codes, it’s like reading the description of the problem.
An object in OOP havs state, behavior and identity(unique memeory space). - Grady Booch
A class describes a set of objects that have identical characteritics and behaviors.
Concept of Class: first used directly in Simula-67
Access Control: keep a boundry between class creators and client programmer.
Composition, Inheritance and Delegation are ways of code reuse.
Difficult to know when to destroy an object (not know if other resources useing it)
Manually Control
Determine objects storage and lifetime while the program is written.
Let programmers control object life time by choosing to put the objects on the stack or in the static storage area. (automatic variable).
With a priority on the speed of storage allocation and release.
Dynamic Approach
Objects are created dynamically in a pool of memory called the heap.
Their number, lifetime, type are determined until run time.
Because the storage is managed dynamically at tun time, allocating storage maybe slower.
One problem: how to determine lifetime?