|
|
|
|
|
by striking
4222 days ago
|
|
(I don't think this is a strictly Python-based argument, so I'll expand to all of OOP.)
I agree with the sentiment that Object-Oriented Programming is only useful in certain cases. Personally, as long as there's enough encapsulation that components can be composed and utilized well, classes are not useful. Pros: enforced encapsulation, things mix and match easily, inheritance (sometimes useful) Cons: over-organization/God objects/anti-patterns (especially of the inheritance variety), bad garbage collection patterns, classes that are "only behavior and not state" [1]) (Also, if it ain't broke, don't rewrite it. Not unless their programming concerns have been conveniently redacted from your post.) [1]: http://eev.ee/blog/2013/03/03/the-controller-pattern-is-awfu... |
|
Expanding loses important context.
> Pros: enforced encapsulation, things mix and match easily, inheritance (sometimes useful)
As an example of the point above about context, Python -- and this is common among dynamic OO languages as opposed to C++/Java-style static class-based OO languages -- has encapsulation by convention rather than enforcement.
> Cons: over-organization/God objects/anti-patterns (especially of the inheritance variety), bad garbage collection patterns, classes that are "only behavior and not state" [1])
I don't think any of these are cons of OOP. All but the last are doing OOP badly -- but any paradigm can be done badly.
The last is not OOP, though its something that can be done in most OO languages. OTOH, there's no real reason to oppose it other than OO fundamentalism -- an object or class that contains only behavior and not state may not be really an example of OOP, but its not a "Con" of OOP, its just a manner in which modules as found in many procedural/functional languages can be implemented in some languages where OOP is the paradigm from which the primary syntactic structures are drawn.