4.1.2 Programming Paradigms: Object-Orientated Programming

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/30

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

31 Terms

1
New cards

What is an object?

Containers of data and containers

2
New cards

What is insantiation?

The process of creating an object from a class

3
New cards

What is a class?

Specification of what properties (data) and methods (instructions) objects of their type will have

4
New cards

What is a class definitition?

Expression of a class on paper

→ Lists a class’ name, properties and methods

5
New cards

What does it mean if a property is private?

Can only be accessed from within an object

6
New cards

What does it mean if a method is public?

Allows an interface for accessing and modifying a class’ private properties

7
New cards

What is encapsulation ?

Combining methods and procedures to form an object

→ Object said to encapsulate its contents

8
New cards

What does encapsulation allow for?

Large programs to be split acorss a team of developers, each of whom can develop a class independently

9
New cards

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

10
New cards

What is good about inheritance?

Promotes code reuse

11
New cards

What kind of relationship does inheritance create?

‘is a’

12
New cards

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

13
New cards

What is an overridden method?

Has the same name as a method in an inherited class but a different implementation

14
New cards

What kind of relationship does association create?

‘has a’

→ e.g. car and driverrelationship

→ Objects where one object contains or is composed of another

15
New cards

What are the types of association?

  • Aggregation

  • Composition

16
New cards

What is aggregation?

  • Weaker kind of association

  • Object will still exist if its containing object is destroyed

  • e.g. a car and its passengers

17
New cards

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

18
New cards

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

19
New cards

What are the design principles of OOP? (3)

  • Encapsulate what varies

  • Favour composition over inheritance

  • Program to interfaces, not implementation

20
New cards

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

21
New cards

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

22
New cards

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

23
New cards

What is a class diagram?

Visual representation of the relationships that exist between classesW

24
New cards

How are classes represented in a class diagram?

Boxes

25
New cards

How are relationships represented in a class diagram?

Connectors

26
New cards

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

27
New cards

How is associatation should in class diagrams?

  • Aggregation: unfilled diamond-headed arrow

  • Composition: filled diamond-headed arrow

28
New cards

How can class boxes be split?

  • Name

  • Properties

  • Methods

29
New cards

How are public properties and methods indicated?

+

30
New cards

How are private properties and methods indicated?

-

31
New cards

How are protected properties and methods indicated?

#