5 ms·
This is a great reply. If you don’t use classes to define behavior for objects that manage their own state, there’s no point in using OOP.
by rclayton 7y ago
This is a great reply. If you don’t use classes to define behavior for objects that manage their own state, there’s no point in using OOP.
- gchamonlive 7y agoI don't think you actually do state management in OOP, only manage a single level of abstractions. In java, inheiretance is directional in a single way, but if you instantiate a singleton component, you can end up affecting the state of every other class that uses that same component. This is not wrong per se, it is a property of OOP in itself. If this rubs you the wrong way, possibly you should be working in purely, monadic functions.
- BiteCode_dev 7y agoIn think singleton has been labelled as anti-pattern in OO for a long time. Having a single reference is useful, but using instantiation as a way to get it has proven a bad design decision.
- gchamonlive 7y agoThat is really my point. Isn't it better to just use a tool that limits what bad decisions you can make? Or at least make these bad decisions so hard that once you know how to implement them, you know better ways to write your code?
- bernawil 7y agoOOP has come to mean different things at different times. For a time, OOP definitely meant tightly coupling state and behavior. Same as inheritance, this practice seems to have been left behind some time ago.