Showing posts with label uml. Show all posts
Showing posts with label uml. Show all posts

Rethinking systems analysis and design

is an excellent book by Jerry Weinberg (isbn 0-932633-08-0). As usual I'm going to quote from a few pages:
We don't need another "movement" just now - unless it is something analogous to a bowel movement - something to flush our system clean of waste material that we've accumulated over the years.
When dealing with the unknown, it appears to be better to handle one situation at a time, examine the results obtained, and then prepare a plan for the next situation.
How to master oneself? The Eastern philosophers have always understood, but it seems the most arduous lesson for us westerners. One masters oneself by giving up the attempt. By approaching an interview with the attitude that one cannot be absolutely in control, one attains the utmost possible control.
One of the greatest divisions [of human thought] is between static and dynamic schemes, between thing and process, between noun and verb.
The architect without the stonemason is not designing cathedrals, but castles in the air.
The way things are is always fighting with the way things might be.
The rough sketch has several advantages over the precise drawing: it represents less investment in time, so we're not afraid to throw it away and try something else; its very roughness conveys important information about where we are in the design process.
The ability to decide when to stop is a feature not a failure.
90% of aggravation in programming projects comes at the end.

Models and abstraction

My friend Kevlin Henney recently did a in-the-brain-of talk for SkillsMatter. He talked about Models and Modelling. Here's part of Kevlin's definition of a model

A model is an abstraction ... for a purpose.

There is an intimate relationship between a model and its abstraction. I think it was Andrew Koenig who said

Abstraction is selective ignorance.

The word 'ignorance' might mislead you here. It doesn't mean ignorance in the sense of an ignorant person - a person who should know something important but doesn't. It means ignorance in the sense of not being aware of something unimportant. The word 'selective' relates to the word 'purpose'. A clear purpose helps you decide what's important and what's not. Things that aren't important can then be omitted. Modelling is primarily an act of omission. The less clarity of purpose in your mind, the less omission is likely to take place, the more the model will try to say, without clarity.


The London underground tube map as a nice example of modelling. The usefulness of the tube map is directly related to the massive amount of omission in it (or should that be not in it?)

  • it's not scaled - 5cm on the map does not relate to 5 miles on the ground.
  • it's not proportional - stations 8cm apart on the map are not twice as far apart (on the ground) as stations 4cm on the map.
  • it's not relative - stations north/south of each other on the map are not necessarily north/south of each other on the ground.
  • it doesn't tell you street names.
  • it doesn't tell you where the bus stops are.
  • the turns in the River Thames are not all 90 degrees or 45 degrees.
  • the little nicks on one side of the line don't tell you if the platform will be on the left or right.
  • ...
These things are all omitted because they don't relate to the model's primary purpose - to help you get from one tube station to another tube station.


Things that a model does say should be said consistently. For example, the station names are all written horizontally, in the same font and style. If some were horizontal, some vertical, some slanted, some in black, some in blue, some large, some small, we might start wonder if the differences were significant. The model would be leading us astray. If the tube map was trying to be geographically accurate some parts of the map would get very squashed. The squashed stations might get a smaller font. And some might be angled into the only available space.


There is also at least one act of addition in the tube map. The lines have different colours. The circle line is yellow for example. Kevlin promises me that the steel tracks on the circle line are not yellow! But then again, perhaps the colour refers to the trains running on the track. Are the trains on the circle line noticeably yellow? If so, which had the yellowness first, the tube lines on the map or the actual trains? Or, over time, have they influenced each other?


It's easy to ignore just how much effort went into figuring out what to remove from the tube map. Wikipedia has a nice entry on how the tube map has changed over time. I remember once reading how Harry Beck spent years working on an early version of the tube map which his supervisor rejected because it needed to contain less.


A powerful abstraction helps you create a model of clarity, but the clarity can easily seduce you - you're not aware of all that has been omitted, and the effort needed to omit it. When you look at the tube map you just see the tube map.



What's missing in this UML inheritance?




Answer - the interface client...



That's better!

Upside down UML inheritance

Here's how inheritance is typically drawn in UML.



When the top two classes are in one package and the bottom class is in another package the effect is to create a package dependency pointing upwards (think of the inheritance triangle as a fat arrowhead). It's odd that this style for drawing inheritance is so dominant as it is in stark contrast to how package/layer dependencies are typically drawn - pointing downwards. The solution is simple - rotate the diagram!



However, associations are conventionally drawn left to right. Again the solution is simple - this time the diagram needs a reflection!



UML modelling with fridge-magnets

Whiteboards are a great UML case tool. They help to make modelling a social activity. They help to emphasize that the act of modelling and the understanding it produces is just as valuable as the resulting model. The wipeability of whiteboards is also a great feature. It encourages modification and experimentation.

Whiteboards are not so good when you want to rearranging a diagram though. But... it occurred to me that if the whiteboard is magnetic then fridge-magnet-style UML-shapes might help. So I found a company that sells magnetic sheet and paid a bit extra to have it coated with a dry-wipe surface. The first sample arrived today and I've made my first prototypes. I cut out two sizes of rectangles and edged them with a permanent marker. Here's one of the larger ones (the background is a tablecloth not wallpaper!)



Now simply stick them on the whiteboard - they stick to each other of course:



Here's the big rectangles vertically in 3-section class format:



And horizontally for packages (just draw on the top-left tab):



Here's a 1-section only class diagram overview made from the smaller rectangles:



And just for Pete Goodliffe here's a Booch cloud:



I'm also going to cut out some ellipses for use-cases/scenarios and some rounded rectangles (roundtangles) for activities/states.

Use-Case cartoon speech bubbles

UML Use Case/Scenario ellipses look quite similar to cartoon speech bubbles. And each ellipse is of course supposed to be "spoken" by an actor. So sometimes when I'm coaching/training/etc I cut out ellipse shaped pieces of card and do some role playing.



You can have fun too. For example, developers often phrase their use-cases from the implementation perspective rather than from the actor's perspective. So when they write "Lend a Book" as the name of their Use Case, you can get them to actually try it. Pretend your inside a library, give them a book, and ask them to role play their use case. Like this... (the headband stops their arms from aching)



At which point someone role playing a Librarian can react like this...



...which makes everyone realize they should really have written this: