Ask HN: What do you think about using classes in Python?
1–10 of 20 posts
Re: Ask HN: What do you think about using classes in Python?
#2Why, doesn't it work?
Always potentially a bad idea, regardless of what you're changing to.
Re: Ask HN: What do you think about using classes in Python?
#3You learn a lot and hate programming...
Unless the codebase is awesome.
Ha!
Re: Ask HN: What do you think about using classes in Python?
#4difficult to comment properly without more context.
Re: Ask HN: What do you think about using classes in Python?
#5Pros: 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...
Re: Ask HN: What do you think about using classes in Python?
#6* If your python code is organized in such a way that your classes will end up having no instance vars or methods, pragmatic advantages to using classes are limited. In other words, if you're switching to OOP, make use of that paradigm or it will indeed feel like mere boilerplate.
Re: Ask HN: What do you think about using classes in Python?
#7Are you sure you are not adopting Java or C++ conventions?
Python supports both OO and functional paradigms. For any project you would use the combination that is optimal for the project. Forcing the use of one or the other without considering the overall impact is unwise.
Re: Ask HN: What do you think about using classes in Python?
#8if they mean "turn the currently fat, repetitive scripts into slim wrappers which call into a well-structured collection of well-composed classes of objects, which closely match the problem domain, thus promoting code reuse, and fix once, benefit everywhere behavior", then good. difficult to comment properly without more context.
Re: Ask HN: What do you think about using classes in Python?
#9> they want to change all the python code Why, doesn't it work? Always potentially a bad idea, regardless of what you're changing to.
Re: Ask HN: What do you think about using classes in Python?
#10Let me guess what's happening here. Some kid recently read the gang of four design patterns book and now thinks he can turn your battle tested scripts into reusable extensible modules?