←back to thread

873 points belter | 1 comments | | HN request time: 0.228s | 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. MajimasEyepatch ◴[] No.42950996[source]
I begrudgingly have had to enter the world of Spring Boot over the last couple years, and this drives me nuts. Every damn thing needs getters and setters so that the ten thousand magic Spring annotations can mutate things all over the place. If the business logic is complex, I try to make immutable domain models separate from the models that have to interact with Spring, but that can require a lot of boilerplate.