Re:Alan Kay on the Meaning of “Object-Oriented Programming” ...
by mav3rick on Sunday March 17, 2019 @11:59PM
(#19418601)
This is one more layer of abstraction that was unneeded. In your example you went through all the trouble to get the same result. Where as there is no notion of a Job inside the person encapsulation (since you don't set a job field ). It's just the salary the object cares about. So why pass in a Job. It so confusing for the reader.
[ Parent
| on HN ]
Re:Alan Kay on the Meaning of “Object-Oriented Programming” ...
by miskin on Monday March 18, 2019 @05:13AM
(#19419635)
That example is correct, because in OOP you should not simply change state/value inside other object, because you pretty much end up with anemic domain model where classes are just structs and code that modify it is not part of the class. What parent meant was that you call "accept new job" on person object and then use this object instead of just setting the salary. Maybe it was oversimplified, though.
Re:Alan Kay on the Meaning of “Object-Oriented Programming” ...
by tpush on Monday March 18, 2019 @06:36AM
(#19419989)
„[...] in OOP you should not simply change state/value inside other object, because you pretty much end up with anemic domain model where classes are just structs and code that modify it is not part of the class.“
Yep, and that’s pretty much the simplest and most modular design for that problem.
This is one of the cases where OOP(whether using methods or messages) leads to more coupling and less flexibility.
Re:Alan Kay on the Meaning of “Object-Oriented Programming” ...
by mav3rick on Monday March 18, 2019 @11:30AM
(#19421882)
I know what the parent meant. Your explanation now directly contradicts what the code does because even with the Job method you are directly setting salary except now it's a more circuitous way for the sake of abstraction. The person class has no notion of a Job.
Re:Alan Kay on the Meaning of “Object-Oriented Programming” ...
by dwd on Tuesday March 19, 2019 @07:36AM
(#19429851)
MVC is not OOP (at least not what OOP was originally) and it's a shame that corruption of the idea was allowed to creep in.
I do like your use of the word "anemic" to describe the method free classes that pass for objects these days.