Objects as a programming concept IB Computer Science
Objects as a programming concept IB Computer Science
HL Topics 1 -7, D 1 -4 1: System design 2: Computer Organisation 3: Networks 4: Computational thinking 5: Abstract data structures 6: Resource management 7: Control D: OOP
1: System design HL & SL D. 1 Overview 2: Computer Organisation D. 1 Objects as a programming concept 3: Networks D. 1. 1 Outline the general nature of an object D. 1. 2 Distinguish between an object (definition, template or class) and instantiation D. 1. 3 Construct unified modelling language (UML) diagrams to represent object designs D. 1. 4 Interpret UML diagrams 4: Computational thinking D. 1. 5 Describe the process of decomposition into several related objects D. 1. 6 Describe the relationships between objects for a given problem D. 1. 7 Outline the need to reduce dependencies between objects in a given problem 5: Abstract data structures D. 1. 8 Construct related objects for a given problem D. 1. 9 Explain the need for different data types to represent data items D. 1. 10 Describe how data items can be passed to and from actions as parameters 6: Resource management 7: Control D: OOP
Topic D. 1. 6 Describe the relationship between objects for a given problem
Three types of relationships There are three main types of relationships between objects: –Dependency – “uses” –Aggregation – “has a” –Inheritance – “is a” Note: Sometimes we just use a plain arrow to show ‘a connection’ rather than a specific relationship.
Dependency, Aggregation, Inheritance
Step 1: Break project into classes
Step 2: Decide States & Behaviours
Step 3: Check inheritance More about this in D 2
Step 4: Aggregation? The weak form of aggregation is denoted with an open diamond. This relationship denotes that the aggregate class (the class with the white diamond touching it) is in some way the “whole”, and the other class in the relationship is somehow “part” of that whole.
Step 5: Any dependents? Sometimes the relationship between a two classes is very weak. They are not implemented with member variables at all. Rather they might be implemented as member function arguments. For example, the Draw function of the Shape class.
Exam style question: Important to note: Know how to identify relationships both in UML and Java. The two big ones is inheritance (“is a”) and dependence (“uses a”) Know WHY we use these relationships
The five steps of object breakdown 1. Break project into objects/classes 2. Decide on states and behaviours for each class/object 3. Check for / Cater for inheritance 4. Check for aggregation (don’t worry about this too much) 5. Identify any dependents and code accordingly
- Slides: 13