4 ms·
> I hardly ever write classes anymore; I write functions. I've never understood why so many people insist on this false dichotomy. I do both. These past year
by hota_mazi 6y ago
> I hardly ever write classes anymore; I write functions.
I've never understood why so many people insist on this false dichotomy.
I do both.
These past years, I feel that I've been writing much better functions as my understanding of more advanced concepts has ramped up, thanks to functional programming and the emergence of things like Rx and coroutines, but once I have these functions, I am extremely happy to be able to organize them in classes and modules and leverage various forms of polymorphism to make my code base flexible and easy to maintain.
- choward 6y ago> I've never understood why so many people insist on this false dichotomy. > I do both. Are you talking about methods attached to your classes or functions that are at the root/module level? If it's on a class I would argue it's not a function since it takes input that's not just the parameters to the function. If it doesn't access properties of the class, then whey does it need to be attached to the class? For example, let's say there is a function that takes instances of two different classes and returns an instance of another class. If you want to move that function to a class, where does it go? > once I have these functions, I am extremely happy to be able to organize them in classes and modules I understand the organizing into modules and being able to create interfaces/types, but why classes?