Resource Management  

Resource management is the killer app for objects

Sometimes data is not just data. It may hold onto extra-linguistic resources like file descriptors, or have a life-cycle that's tied to the business goals of the program (e.g. gui objects). It may also be holding on to memory or be causing itself to leak (e.g. an object that has caused another object to subscribe to its changes).

Disposable is a great case for subtype inheritance. because it's the kind of trait can't be safely managed in an ad-hoc fashion.

Likewise, streams that wrap each other over and over (filestream -> bufferedstream -> pushbackstream) map much more nicely onto objects than functions+data.

Comments powered by Disqus