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:
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.
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.