A Funny Java Flavoured Look at the World

Monday, October 30, 2006

Are The Principles of OOD out of fashion?

About a year ago or more (time flies pretty quick) I found some articles on Design Patterns and these bad boys blew me away and I have written many blogs about them but here is a more recent blog entry on Why Design Patterns are useful. I quickly looked for more information on Design Patterns because firstly they seemed to be solutions for common problems but I didn't really realize they were common problems e.g. The factory pattern, I didn't realize why it was a good idea to create about objects and assign them to an interface. Not until the factory pattern explained the problem and then the solution.

I will get back on track because I am not here to talk about Design Patterns today, I am here to talk about Principles of OOD. Sometimes I pop articles into a word document to read later and to blog about. Today I dipped into that word doc and found this fantastic article

The Principles of OOD


The reason I am talking about Design Patterns is because recently they seemed to me to have become very fashionable and everyone is talking about them, writing books about them and articles (like the one I wrote) talking about them but it doesn't seem to me that many people are talking about the principles of Object Oriented Programming, which I believe is what Design Patterns are built on. It's like OO has gone out of fashion but Principle of OO are just as important as Design Patterns because basically they give you the tools to create your own Design Patterns but you would struggle to do that without understanding Object Oriented Design.

After I read about Design Patterns it lead me backwards to trying to hunt down articles about OOD and I then read loads of the articles on the Object Mentor site which is where this article points too. It also has the craftsman articles which I just like and have blogged about before here.

It was after reading the OOD articles that I appreciated the Design Patterns even more because I could see what principles were being used in the Design Patterns. The most interesting of the principles is the

The Open Closed Principle

I keep seeing this in my code more and more. It always gives me great delight (in a very sad way) to be able to use a piece of code I have written earlier but without changing the code, just adding my changes around it. Not having to change the tested code gives me confidence that the code is more likely to work without me adding any bugs to it.

Recently I have been searching for Object Oriented books and I am finding more and more but there seemed initially quite hard to bump into (especially good ones) but then this could be my poor book searching ability.

I would like to here what you think, has Object Oriented Design gone out of fashion, is it right to have been pushed out. I often read articles which state OO principles alone will not lead to good code. I definitely think Design Patterns have managed to recently been in fashion and dare I say a bit overhyped, in some ways it is a bit of a short cut but then in other ways it is a good learning tool (amusingly for this article OOD).

Amusing IT Stories is my new funny IT blog and needs contributions from developers, please check it out and contribute.

2 Comments:

  • I'm not clear on what you're asking in your title. So instead of giving a direct and to-the-point answer, I'll give one of my usual rambles.

    The term "object oriented" is used by different people to mean some very different things. Robert C. Martin pretty much hijacked the old UseNet comp.object newsgroup and used it to promote a number of papers that he wrote on the subject. The Gang of Four design patterns are solidly in Martin's camp, and proved to be a significant endorsement of the Martin viewpoint. During the late '90s and into the beginning of the 21st century, Martin's view pretty much prevailed, but it is no longer the only recognized Truth.

    Alan Kay is generally credited as having invented the term "object oriented" along with SmallTalk. Kay has repeatedly said that the sorts of things that Robert C. Martin espouses are not at all what he (Kay) means by "object oriented".

    Two other strong views of object orientation were championed by Bertrand Meyer and by Peter Coad. These also had little to do with what Robert C. Martin is on about—nor with each other, for that matter.

    A fifth view—one that is almost completely unknown among serious programmers—can be found in the implementation of MushCode. Where the other viewpoints tend to actually be "class-oriented", MushCode has only objects and no classes. Code is associated with objects, not with classes. I suspect that Alan Kay might approve.

    Recently, untyped languages and "duck typing" (Ruby being a prime example) have been winning many converts away from Robert C. Martin's viewpoint. Martin's notion of OO is based on interface definitions, inheritance of those definitions, and polymorphic substitution. The new languages come closer to the Kay viewpoint. Users of those languages might understand why Kay has repeatedly disparaged the Martin definition of "object oriented".

    I can't really say if the Ruby approach to OO is essentially the same as Kay's or if it is yet another view of what "object oriented" means. I'm not au fait with Kay's work like I am with the others.

    So in summary: Robert C. Martin's view of object orientation was well-received for about a decade, but now is losing ground as programmers become familiar with languages such as Ruby which are closer to what Alan Kay originally had in mind (at least I think that's what he had in mind). Other viewpoints held by Bertrand Meyer and Peter Coad have a few adherents—including me—and MushCode provides an interesting if virtually unknown alternative view.

    By Blogger Doug, at Tue Oct 31, 06:00:00 pm 2006  

  • An interesting viewpoint. I've not spoken to Kay about his view, nor heard him disparage mine. I have spoken to both Meyer and Coad, and find that we have quite a bit in common.

    I think it's interesting that Doug points out that the Design Patterns books supported my view. I agree. Yet the Design Patterns movement was started by the Smalltalk community, and at least one author (Johnson) is a Smalltalk programmer.

    Finally, I agree that languages like Ruby have caused quite a stir; and that is something I am glad of. I think the concepts in Ruby are important, and that all programmers should learn them.

    I'll also agree that the style of programming we see in Ruby does not necessarily conform to my OO principles. This was also true of early Java programs, early C# programs, and early C++ programs. Indeed, I think the key word here is "early". For the most part the principles are not language specific, nor even static type specific. They are simply different ways of expressing that code should enjoy a strong separation of concerns.

    The Ruby community has begun to re-learn the need for strong separation, and with them the need for the OO principles. Rails is a prime example of a framework based on those principles and upon that separation.

    By Anonymous Anonymous, at Tue Nov 14, 10:20:00 pm 2006  

Post a Comment

<< Home