Hacker News new | ask | show | jobs
by xixixao 1457 days ago
> Adherence to this principle in OOP means aggregating the code as methods of a static class.

This is not OOP, this is a way to do functional programming in a class-based language that lacks top-level function declarations / modules.

While this might seem a nit pick it makes me sceptical about the rest of the content.

1 comments

I think possibly what they meant is "when using an object oriented language like Java or C#", aggregate the code as methods of a static class.
That's not necessary either. What we're talking about here is an analog for the real problem, which is "when using an object oriented language, write pure functions even though the language doesn't make you do it".

Static functions introduce friction against making impure functions, but not an overwhelming amount of it. If it's all you have, then there are worse safety blankets, but it's not going to solve your lack of buy-in problem. If everyone is on board then you don't need static functions. If they aren't, static functions aren't going to save you, they're just going to extend the amount of time you suffer before you wise up and get a new job somewhere else.

If all of the data structures are maps of maps of maps, it seems that it would be obvious to use static methods in this situation. I don't understand the use case for instance methods with this arrangement.
Lazy evaluation for one. Organization for another.