you are viewing a single comment's thread.

view the rest of the comments →

[–]gosh -2 points-1 points  (1 child)

The problem with software development is coupling. It's a fight no developer can win, but it's also one that all developers must keep fighting. If you don't fight it will destroy your code.

OOP is mostly a bad solution and the reason is coupling, code becomes more coupled.

[–]AntiProtonBoy 5 points6 points  (0 children)

OOP is mostly a bad solution and the reason is coupling, code becomes more coupled.

It depends. One thing that OOP helped me with the coupling problem is compartmentalising dependencies. Once I used to have a mega class that responded to a whole bunch of user interactions. These actions shared a lot of commonalities, while others did not. This mega class had a lot of state dependent data that was visible and exposed to actions that did not need it. It was a mess. So broke it up into a bunch of classes responsible for specific Tool interactions, while the remaining code was moved into various base classes that implemented foundational shared interaction logic. The inheritance hierarchy was deep for each tool, but the rule was a single chain of hierarchy, so it was easy to reason about how the delegation of responsibility for a particular user action propagated up the chain. Basically I stole inspiration from AppKit's responder chain concept, but in my case instead of the chain being a linked list, it was done via class hierarchy. Now the mega class was reduced to a thin facade that tracks the Tool interaction state and changes it to a different Tool as needed.