Chapter27. A More Realistic Example Flashcards

(4 cards)

1
Q

Python’s Class System

A

This is what Python is all about. Object-Oriented-Programming. It is largely a matter of searching for an attribute in a tree of objects, along with a special first argument for functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Software design concept: Encapsulation

A

To wrap up operation logic behind interfaces, such that each operation is coded only once in our program. We want to code operations on objects in class methods, instead of littering them throughout the program. That way, if our needs change in the future, there is just one copy to update – factoring code to remove redundancy and thus optimise maintainability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

OOP The Big Idea: Customisable Hierarchies

A

The customisable hierarchies we can build with classes provide a much better solution for software that will evolve over time. We can tailor and extend our prior works by coding new subclasses, we can leverage what we’ve already done rather than; starting from scratch each time, or breaking what already works, or introducing multiple copies of code that may all have to be updated in the future. When done right, OOP is a powerful programmer’s ally.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Python’s OOP Machinery

A
Instance creation - filling out instance attributes
Behaviour methods - encapsulating logic in class methods
Operator overloading - providing behaviour for built-in operations like printing
Customizing behaviour - redefining methods in subclasses to specialise them
Customizing constructors - adding initialisation logic to superclass steps
How well did you know this?
1
Not at all
2
3
4
5
Perfectly