Real-Life Uses for OO
Personally, I hate blog titles that misrepresent the content of the post. Unfortunately though, as much as I’d like to write about all the real-life examples of OO out there, they don’t appear to exist.
A large amount of proof that OO does not apply well to real life problems is included in textbooks. I am yet to see a textbook on OOP, OOD or any acronym beginning with OO which attempts to prove OO’s benefits without using either a banking system or graphical shapes.
In fact, I went through the first 10 Google responses to a query for ‘object oriented examples’ and grouped them:
Trivial Examples
http://www.softwaredesign.com/objects.html
This page’s “Real Life Examples” of OO demonstrate how Smalltalk can add the numbers 1 and 2 just as easily as C. It also demonstrates that adding strings results in a concatenated string – an ability which many previous languages have provided without using OO.
http://www.cs.gordon.edu/courses/cs211/AddressBookExample/index.html
This page almost worked it’s way out of the trivial section, but not quite. An address book is a nice variation from a bank account, but the problem could be much more efficiently and effectively solved using a database (note that a database would probably be used to store the objects anyway – why have a middle man?)
http://www.eimc.brad.ac.uk/java/tutorial/Project/1/ooprim.htm
http://java.sun.com/docs/books/tutorial/java/concepts/object.html
The examples on both of these pages are interesting. I’d never actually seen a bicycle ‘simulated’ in OO. Not that it proves anything. I was quite disappointed that the Sun page didn’t have a better example.
Banking Examples
http://www.math-cs.gordon.edu/local/courses/cs211/ATMExample/
http://www.developer.com/design/article.php/3387591
http://ratio.co.uk/W1.html
And here come the bank accounts. The first is actually a rather complicated ATM example and is actually the best example I’ve seen. The other two are typical bank account examples.
http://en.wikipedia.org/wiki/Object-oriented_programming
The Wikipedia entry avoids getting into the realm of examples – probably a good move judging by the rest – but doesn’t do much to push the idea that ‘OO models real-life easier’:
Subject oriented: The Sales Application prints the Receipt
Object oriented: The Receipt prints itself upon receiving a message from the Sales Application
I don’t know what real-life that contributor was living it, but I’ve never seen a receipt print itself. And to be honest, if anyone told me that they had, I’d slap them sillier.
The best application for OO is inside the computer. Windows, controls and devices. Real-life uses? Sorry, not buying it.
