5 ms·
Can you point to any good tutorials for replacing OOP with functional patterns in Python? I often use OOP to semantically group functionality and "manage" state
by shackenberg 8y ago
Can you point to any good tutorials for replacing OOP with functional patterns in Python? I often use OOP to semantically group functionality and "manage" state e.g. avoiding methods with multiple variables or cases where I have to pass one (not changing) variable to multiple functions.
- virmundi 8y agoSounds like you discovered that OOP and Functional are the same thing. Closures are the poor-person's objects. Objects are the poor person's Closures. If you never mutate the internals of an Object, or mutate with copy, isn't just a coherent closure? Checkout http://wiki.c2.com/?ClosuresAndObjectsAreEquivalent http://wiki.c2.com/?ClosuresAndObjectsAreEquivalent
- shackenberg 8y agoIf they are the same thing, why does the parent commenter prefer Functional?
- virmundi 8y agoPersonal choice. Some people like the idea of splitting the data from the functions that operate on it. Others don't like mutability and presume that OOP requires it. Scala and other languages make it easy to have immutability and OOP. Look at Clojure. The interfaces look a lot like Object definitions.