1/30
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is an object?
Containers of data and containers
What is insantiation?
The process of creating an object from a class
What is a class?
Specification of what properties (data) and methods (instructions) objects of their type will have
What is a class definitition?
Expression of a class on paper
→ Lists a class’ name, properties and methods
What does it mean if a property is private?
Can only be accessed from within an object
What does it mean if a method is public?
Allows an interface for accessing and modifying a class’ private properties
What is encapsulation ?
Combining methods and procedures to form an object
→ Object said to encapsulate its contents
What does encapsulation allow for?
Large programs to be split acorss a team of developers, each of whom can develop a class independently
What is inheritance?
Mechanism that allows a new class to acquire the properties and methods of an existing class, while also having its own properties and methods
What is good about inheritance?
Promotes code reuse
What kind of relationship does inheritance create?
‘is a’
What is polymorphism?
The ability of different classes to be treated as instances of the same class through a common interface, allowing methods to be used interchangeably
What is an overridden method?
Has the same name as a method in an inherited class but a different implementation
What kind of relationship does association create?
‘has a’
→ e.g. car and driverrelationship
→ Objects where one object contains or is composed of another
What are the types of association?
Aggregation
Composition
What is aggregation?
Weaker kind of association
Object will still exist if its containing object is destroyed
e.g. a car and its passengers
What is composition?
Stronger kind of association
If the containing object is destroyed, the associated object is also destroyed
e.g. car and its wheels
What are the strengths of using OOP? (5)
Clear program structure
Easier developing and testing
Division of large projects
Reuse of code
Space efficiency of code
What are the design principles of OOP? (3)
Encapsulate what varies
Favour composition over inheritance
Program to interfaces, not implementation
What is meant by ‘encapsulate what varies’?
Any requirements which are likely to change in the future should be encapsulated in a class
→ Any changes can easiy be made as required
What is meant by ‘favour composition over inheritance’?
Composition should be used over inheritance where possible
→ Composition is seen as more flexible relationship
→ Inheritance should be used when composition is not appropriate
What is meant by ‘program to interfaces, not implementation’?
Allows unrelated classes to make use of similar methods
An interface is designed as a collection of abstract procedures that can be implemented by unrelated classes
When a new object is created, it can implement an interface which it provides with the correct properties and methods
What is a class diagram?
Visual representation of the relationships that exist between classesW
How are classes represented in a class diagram?
Boxes
How are relationships represented in a class diagram?
Connectors
How is inheritance shown in a class diagram?
Unfilled arrows which point from an inherited class towars the class which inherits it
→ Should always point upwards
How is associatation should in class diagrams?
Aggregation: unfilled diamond-headed arrow
Composition: filled diamond-headed arrow
How can class boxes be split?
Name
Properties
Methods
How are public properties and methods indicated?
+
How are private properties and methods indicated?
-
How are protected properties and methods indicated?
#