UML & Design Anti-Patterns


First off it’s worth saying that I use UML a lot and glad that we have a somewhat standardised way of communicating  our models, this post is not a dig at UML but rather some anti-patterns I have come across in relation to people using UML.

Where’s the Behaviour

When we are thinking about objects we should be thinking about the behaviour an object performs, what messages does it accept, other objects it uses perform it’s behaviour etc… And yet time and time again all I see is class diagrams this is no good, class diagrams are static and don’t provide us with enough information to show it’s behaviour instead you should start with dynamic diagrams i.e. collaboration diagrams or sequence diagrams these provide us with a much better way to model the behaviour of our objects:

user repository

If we compare the two diagrams we can see that the class diagram makes us perceive that the object sits on it’s own and exposes some messages it accepts, however in the sequence diagram we have already began to think about what other objects will use the object were designing and the collaborating objects it uses this gives us a much better idea about how we can start to implement the design.

Michelangelo Effect

UML should be used to go through quick design examples, not to create a work of art! You should not be getting hung up on every little semantic detail (should this line be dotted or filled, do I need to underline this etc…) as long as the general rules of the model are followed that’s enough. Don’t spend time trying to stick to every UML specifications you won’t get any benefit from doing so, this one of the reasons I prefer to use a whiteboard or simple pencil sketches rather than  UML tool such as visio as it’s conformity to every single rule slows you down.

Modeling the World 

You should model within a reasonable context, not try and model the system as a whole. We use UML to go through some designs of the system and in these cases we are concentrating on a particular context of the system, when we use UML we should be modeling only the items that make sense for this context once we start modeling the whole system we get bogged down in details that hinder rather than help us work out the design. This is somewhat related to the above anti-pattern in that we start treating UML models more than just sketches to help with designing.


4 thoughts on “UML & Design Anti-Patterns

  1. I have noticed the same problem in my students, they tend to focus solely on the static aspects when thinking about an OO model.

    I think many text books are flawed in the way they present OO design and UML.

    I strongly believe in behavior-driven design for OO, glad to read you do as well. One problem I had was that sequence diagrams were so cumbersome to create and update.

    So I created my own UML sequence diagram editor to make that task easier, it should make it easier for you as well.

    Let me know what you think of it, I’m always glad to get feedback!

  2. I have a significant new release coming up you might want to try out. It’s not yet available online, contact me if you’re interested in giving it a try or perhaps reviewing it for your blog to complement the article.

    I didn’t find a way to contact you offline, so I posted it here (feel free to remove this comment when you’ve read it).

Comments are closed.