objects being like biological cells and/or individual computers on a network, only able to communicate with messages (...) OOP to me means only messaging, local retention and protection and hiding of state-process” https://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en 6
internal state along with a collection of method calls that let you modify this state, and programs consist of making the right set of state changes.” https://docs.python.org/3/howto/functional.html 7
special names: double underscore before and after the method name itself: ◦ __new__, __init__, __len__, __del__, __repr__, __str__ … • When writing Python code we shouldn’t call special methods explicitly. Python interpreter does that
a type only on runtime. The variable values have a type and not the variable itself. • Strongly typed: Python restricts how the different types can interact with each other • Duck typing: “if it walks like a duck and it quacks like a duck, then it must be a duck”
it possible to create a Collections-like object? ◦ Inheriting? ◦ Implementing an Interface? ◦ Making it “quack” (behave) like a Collection: following a protocol
everything is an object • Objects have state and behavior • Since Classes are objects as well, class methods should be used when it’s needed to extend a class object behavior 43
These objects normally act as factories for new instances of themselves, but variations are possible for class types that override __new__(). The arguments of the call are passed to __new__() and, in the typical case, to __init__() to initialize the new instance.” 44 https://docs.python.org/3/reference/datamodel.html
These objects normally act as factories for new instances of themselves, but variations are possible for class types that override __new__(). The arguments of the call are passed to __new__() and, in the typical case, to __init__() to initialize the new instance.” 45 https://docs.python.org/3/reference/datamodel.html
Ice Cream Parlor • The owner of the ice cream shop offered a basic flavor of ice cream (vanilla, chocolate, etc) and blended in a combination of extra items (nuts, cookies, fudge, etc.) and called the item a "mix-in" https://en.wikipedia.org/wiki/Mixin
implement business logic • Mixins being used by only one class is a code smell • Ideally someone could remove without too much pain the mixin dependency without breaking the core functionality of an object (loose coupling) • Mixins are never directly instantiated