1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Inheritance
The process of creating a new class based on an existing class (superclass)
Superclass
The class that is being inherited from
Subclass
The class that is inheriting from the superclass
Polymorphism
A concept in programming that allows an object to take on different forms or behaviours
Overriding
A method of polymorphism where the same identifier in the superclass is redefined in the subclass
Association
The relationship between two classes
Aggregation
An association where one class contains or references another, but can still exist independently from the the other class
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.
Abstract method
A method declared in a base class that does not have an implementation. Instead, it is used as a placeholder and must be overridden by subclass methods.
Virtual method
A method declared with an implementation in a base class that can be optionally overridden or inherited from by other subclasses
Static method
A method that is associated with the class itself rather than any object, and it can be called without instantiating the class.
(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())
Interface
A collection of method declarations that must be implemented by any class that uses it. It allows unrelated classes to follow the same protocol.
OOP design principles
Encapsulate what varies
Favour composition over inheritance
Program to interfaces, not implementation
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