Topic 3
Topic 3 has 3 parts: Collaboration, Memory, and UML Sequence Diagrams
Topic 03 - Part A - Collaboration
OOP uses objects that interact with eachother. Object relationships are the backbone of Object Oriented Programs.
There are three main kinds of relationships:
1. Association
Association is used for "has" relationships. Such as "Ben
has a Website
".
2. Aggregation
Aggregation is used when an object is part of something else. Such as "Object Oriented Programming
is part of Computer Science
" or "Reverse Card
is part of the Uno Deck
"
3. Dependence
Dependence is very self-explanatory. It is when an object depends on another one. For example "This website
uses HTML
" or "Soccer
uses Soccer Ball
".
These are mainly used for temporary "use" relationships, hence the terminology.
Topic 03 - Part B - Memory
This part is all about stacks/heaps.
Pointers and references allow objects to be flexibly networked.
When the project runs (runtime), all objects exist in the heap.
Different languages use a "pointer" in order to reference objects.
C# and Java | C++ and Objective C |
---|---|
Reference types Value types | Pointers Types |
Pointers make the flexible relationships happen.
An object is "aware" of other objects, and can request that the other object does something.
Topic 03 - Part C - UML Sequence Diagrams
Another aspect of the UML diagrams the sequence diagrams.
UML sequence diagrams showcase a sequence of communication between different objects. A "message" is sent out and changes over time. They are relatively intuitive to read/understand. A sample of one can be seen below.
Photo credit: Microsoft Visio Docs