Objects, Services, and the Real World

, Aug 15, 2005

Radovan links to and has high praise for a presentation by Steve Jones. I guess you had to be there … anyway, I simply can’t resist attacking one of my favorite pet peeves: the idea that OO was and is successful because “objects model things from the real world”. In my former job I interviewed close to a hundred job applicants (in two years, as opposed to about 20 in the past six years); one of my routine questions was “How would you explain OO?”

Anyone answering with the standard real-world boilerplate had a hard time finding a good answer why, in this respect, an “Order” class should be in any way different from an Order struct in C or an Order table in an RDBMS …

OO successful because objects represent real-world things? You mean, like, files, application windows, linked lists?

Bullshit.

On August 15, 2005 10:39 PM, Clint said:

I think i agree with you. Yet, I might be missing your point. Do you mean to say that OO never does a good job of representing real world things? Or do you mean that people don’t use OO properly to get what they need from the software, in order to represent real world things? I take it you beleive that OO isn’t the only thing that can represent real world things and the OO isn’t successful anymore than RDBMS or C is.

On August 15, 2005 11:12 PM, Stefan Tilkov said:

I think OO is an excellent approach and I’m a big fan and user of it. I just happen to believe that it is a principle for software engineering, nothing more; and an OO software does not do a better or worse job of representing real-word “things” that (most) other technologies. Claiming that it does is just marketing.

On August 16, 2005 12:44 AM, Vincent D Murphy said:

Taking the REST/Web point of view, the object, the struct, the row, the file, the (view within the) window, and so on are all just representations of an abstract resource.

There is a resource, but you can’t touch it or act on it (in a computational process or in your head, it doesn’t matter). You can only say things about it.

I think it is good to take this approach any time you take a bag of bits and think of them as anything more than an integer. That’s where you move from numerical to symbolic computing; and even that could be viewed as a false dichotomy; in that the bag of bits is always a symbol be it for a number or something else.

On August 16, 2005 3:37 PM, Stefan Tilkov said:

Good point, the same is true for REST resources: Useful as they might be, they’re just another way to model things, not inherently more or less close to reality than any of the others.

On September 3, 2005 3:12 PM, Steve Jones said:

As the person who wrote the “bullshit” I have to say the answer to the question is pretty straight forward…

A struct in C (or a database table) has only data and no behaviour. The key difference to an OO object is that it models both the data and the the behaviour. Now you can actually do OO in C by using function pointers et al within structs, and you can model behaviour in databases using triggers et al… but its much much harder.

Linked lists are a normally pure data (limited behaviour) so don’t really push OO at all, application windows however are great examples of how OO helps build things as the window object maintains not only the data about itself but also its constraints and actions. Its that which differentiates Object Orientation from just lobbing data into classes, which I agree is no better than doing structs in C.

OO = Structs + behaviour. And I stand by my comment that this is why OO works… I won’t deny however that its stunning how many people still don’t seem to understand the difference between data and behaviour.

On September 3, 2005 6:11 PM, Stefan Tilkov said:

Hi Steve,

I did not intend to call what you wrote bullshit. My point is only that OO is useful because of many reasons, but not because it models things closer to the real world. Basically all OO practitioners, myself included, end up with modeling objects of distinct roles - some of them represent data, some of them represent processes since more often than not it’s not at all clear what object a given behavior belongs to.

If you look at the GoF design patterns book, you find a lot of useful and common applications of OO; most of them are driven by software engineering needs, not by analysis.

Again, I may have trouble making my point, so I’ll try once more: I like OO; classes are more useful than structs; I prefer even C++ to C; I’m not arguing that a procedural language and an OO language are equal — not at all. My point is that with regards to their resemblance to what’s going on in the real world there’s little, if any, difference.