4 ms·
OO idioms and practices encourage coupling. For example, in Java, if you want behavior you are forced to create a class. In OO instruction classes are often int
by richcollins 14y ago
OO idioms and practices encourage coupling. For example, in Java, if you want behavior you are forced to create a class. In OO instruction classes are often introduced as containers of state. So it’s no surprise that in OO systems you typically find data and behavior mashed together.
Replace class with arguments and you have the same "coupling"
As soon as I get the creative idea of asking if my Cat is of drinking age, I can’t reuse this behavior
Yes you can, you just delegate the behavior to an object whose job it is to determine things about ages. It isn't much different than having a suite of related functions designed to operate on things with ages.
We'll designed software doesn't look much different if you do it in a functional or OO language. The main difference you do see is that much of the code for dealing with state disappears in an OO language as the language itself implements it. In a functional language you have to build your own OO like system to make the stateful parts easy.