Ch 68 - Object-oriented design principles

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/13

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.

14 Terms

1

Inheritance

The process of creating a new class based on an existing class (superclass)

<p>The process of creating a new class based on an existing class (superclass) </p>
2

Superclass

The class that is being inherited from

3

Subclass

The class that is inheriting from the superclass

4

Polymorphism

A concept in programming that allows an object to take on different forms or behaviours

5

Overriding

A method of polymorphism where the same identifier in the superclass is redefined in the subclass

6

Association

The relationship between two classes

7

Aggregation

An association where one class contains or references another, but can still exist independently from the the other class

<p>An association where one class contains or references another, but can still exist independently from the the other class</p>
8

Composition

A strong association where one class contains another contained class that is fully dependent on the container. If the container is destroyed, the contained object is also destroyed.

<p>A strong association where one class contains another contained class that is fully dependent on the container. If the container is destroyed, the contained object is also destroyed.</p>
9

Abstract method

A method declared in an abstract class that does not have an implementation. Instead, it is used as a placeholder and must be overridden by subclass methods.

10

Virtual method

A method declared with an implementation in a regular class that can be optionally overridden or inherited from by other subclasses

11

Static method

A method that is relevant to all the instances of a class, rather than to any specific instance, and can be run without creating an object. (It essentially groups a bunch of methods under one class name for clarity, used in a lot of python libraries, e.g pygame.display.update())

12

Interface

A collection of abstract methods that a class must implement

13

OOP design principles

  • Encapsulate what varies

  • Favour composition over inheritance

  • Program to interfaces, not implementation

14

Why is the OOP paradigm used?

  • Modularity - Breaks down code into classes and objects with clear responsibilities

  • Reusability - Through inheritance, existing code can be used without rewriting

  • Maintainability - OOP is easier to understand and update

  • Encapsulation - Internal object data is hidden from the outside interface