Polymorphism (OOP) (OCR A-Level Computer Science): Flashcards
📚Flashcards
Practise the cards
13 cards from this deck
ShowHide
Practise the cards
13 cards from this deck
Meaning of 'polymorphism'
Meaning of 'polymorphism'
'Many forms'
Type of polymorphism at runtime
Type of polymorphism at runtime
Method overriding
Method overriding definition
Method overriding definition
Child class provides specific implementation of method already defined in parent
Type of polymorphism at compile-time
Type of polymorphism at compile-time
Method overloading
Method overloading allows
Method overloading allows
Multiple methods w/ same name but different parameters
Python's support for true method overloading
Python's support for true method overloading
Not directly supported
Purpose of interfaces in polymorphism
Purpose of interfaces in polymorphism
Ensure different classes provide same methods
Polymorphism benefit: flexibility
Polymorphism benefit: flexibility
Code works w/ different types interchangeably, adaptable
Polymorphism benefit: code reusability
Polymorphism benefit: code reusability
Classes share methods, reducing redundancy
Polymorphism benefit: maintenance
Polymorphism benefit: maintenance
More modular, less complex, improves maintainability
Polymorphism benefit: extensibility
Polymorphism benefit: extensibility
New subclasses can extend/override methods easily
Requirement for overriding method signatures
Requirement for overriding method signatures
Method name and parameters must match parent exactly
Risk of not using polymorphic methods
Risk of not using polymorphic methods
Duplicated code
