5 ms·
Using python, I tend to write much more procedural code than anything else - packages / modules / namespaces are much better for code organization and pure func
by mattbillenstein 7y ago
Using python, I tend to write much more procedural code than anything else - packages / modules / namespaces are much better for code organization and pure functions that don't hold state are just easier to reason about. Classes are used sparingly - really only when you actually should encapsulate some data or state, but generally they're not needed at all.
I've seen oop used as code organization too many times, and it's always a laughable mess.
- tyleo 7y agoOver the years my programming style has changed. I suspect it will continue to change in the future but for now I’m writing my own TypeScript code in a similar style. I tend to use TypeScript interfaces like C structs and write free functions that use them as the first argument. I find that this style works happily with the React hooks api.
- pjmlp 7y agoPython functions are objects, instances of the function class, as this little snippet shows. def afunc(): pass print(afunc.__class__) print(dir(afunc))
- Doxin 7y agoWhile technically a function is a class instance, it doesn't act like one in pretty much any common use-case.