←back to thread

873 points belter | 1 comments | | HN request time: 0.203s | source
Show context
gorjusborg ◴[] No.42947212[source]
No, objects aren't generally 'good', unless you think keeping multiple state machines in sync is 'good'.

OO is not evil, but it also shouldn't be your default solution to everything.

Also, who is this person? I immediately distrust someone who calls themselves 'a pretty cool guy'. That's for the rest of us to decide.

replies(4): >>42948148 #>>42948743 #>>42949044 #>>42949626 #
karmakaze ◴[] No.42948743[source]
The way I like to use OO (usually not real OO, but rather class-based languages) is to minimize its mutable state. Often mutability is merely a lack of using builder patterns. Some state can be useful as long as it's easy and makes sense to globally reset or control. It's like writing a process as a construction of monads before any data is passed into it. Similarly a tree of processing objects can be assembled before running it on the input.
replies(1): >>42949465 #
patrickmay ◴[] No.42949465[source]
Exactly. Automatically adding getters and (especially) setters to a class is something I see far too often.
replies(2): >>42950996 #>>42962149 #
1. gorjusborg ◴[] No.42962149[source]
Agree on both of your takes.

I've probably written more Java than any other programming language during my career, and I've seen both good and bad ways of writing Java.

Bad java heavily uses lots of inheritance, seems to think little about minimizing exposed state, and (unrelated to this discussion) uses lots techniques I like to call 'hidden coupling' (where there are dependencies, but you can't see them through code, as there is runtime magic hooking things up).

Good java almost never uses inheritance (instead composes shared pieces to create variation on a theme), prevents mutability wherever possible, and makes any coupling explicit for all to see.

Good java still has classes and objects, but starts to look pretty 'functional'.