Stephen R. Palmer Software Development www.step-10.com

Home Design Process Tools Books About



Modelling in Colour: Colour Coding Class Archetypes

Although a stereotype tag is a convenient UML mechanism for indicating the archetype of a class, it does hide some very important meaning in a rather plain and simple text label [Coad99]. 

The same could be argued for the standard stereotypes of UML and the designers of UML obviously recognized this because UML allows for alternative ways of depicting stereotypes that help the stereotype stand out more clearly in diagrams. Angle brackets and guillemots are the default way of showing a stereotype but stereotypes can also be shown by a change of graphic symbol or shape.

In figure 1 the Cashier class is drawn using the alternative symbol for the <<actor>> stereotype and the Manager class is drawn using the default representation.


Figure 1: An alternative icon for the actor stereotype next to the default class symbol with text tag indicating the stereotype

There are a number of problems in this approach. Firstly, when the alternative symbol is used it is not easy to list the attribute and operations so they are either omitted from the diagram or are listed underneath the symbol in a rather unsatisfactory manner. One way around this is to stick with the default rectangle but instead of the textual stereotype tag above the class name, display a much smaller version of the stereotype's alternative symbol to the right of the class name (see figure 2). This approach has grown in popularity recently and is used in UML 2.0 to good effect but, unfortunately, it also significantly reduces the ability of the stereotype information to stand out from the rest of the information in a diagram. It is better than the text tag but not by much.

stereotype icon
Figure 2: Stereotype symbol shown to the right of the element name

A second disadvantage of using a non-standard symbol to represent a stereotype is that it fails to communicate to people unfamiliar with the symbols being used.

Thirdly, additional symbols add to the burden of learning to read the diagrams for those new to UML and those who are only occasional users. Most people deliberately restrict themselves to the subset of UML class and seqeunce diagram notation most frequently used. There is more than enough additional notation available for UML class diagrams in the UML specification without us adding more shapes and symbols without a very good reason.

Introduction to UML notation...

Fortunately the UML standard does rather begrudgingly allow us an alternative: colour.

Colour Objections

There are two immediate objections raised when anyone suggests the use of a color-coding scheme. Firstly, because of the difficulty it causes colourblind people. Secondly, because of the problems of reproducing color on grayscale-only printers, copiers and fax machines and the cost of reproducing colour copies.

Retaining the textual tags for our class stereotypes and class archetypes when using colour solves the problem of colourblind people not being able to distinguish one class archetype from another and an appropriate choice of colours keeps the diagrams readable when grayscaled by colour-challenged devices.

These days most projects can afford the cost of an ink-jet printer/scanner/copier for occasional, reasonable-quality, colour, printed output and the increasing use of intranets and mime content in e-mail by project teams means that the use of colour is not quite the technological problem it might have been in the past. However, publishers of books and other high-volume, high-quality printed material may still have good cause to object to the use of colour due to the additional cost involved.

For most of those that have tried object modeling in colour, the benefits of using colour heavily outweigh the objections. So instead of assigning a different shape or symbol to each class archetype we assign a different colour.

A Brief History

As explained by Peter Coad [Coad99], the colours that were originally used are those that happened to be available in multicoloured packets of Post-It notes at United Overseas Bank, Tiong Bahru, Singapore in September 1997. In collaborative workshop style object modeling sessions, we were using Post-It notes to represent classes and objects as we built UML-like class and sequence diagrams on flipchart pads. We very quickly exhausted the stationary cupboard's supply of yellow-only pads of Post-It notes and were provided with packs containing pads in four different colours. Peter Coad, who was facilitating and coaching the sessions, put the colour-coding in place to counter a growing sense of confusion from using the four different colours. This worked so well that Peter went away to research and develop the technique. The results were briefly documented in [Coad 99]. We expand a little more below.

Benefits of using Colour in Modelling

Even without research into colour theory it is quickly clear to most people that try object modelling in colour, that it has very positive benefits.

Firstly, and maybe most importantly, object modelling using colour-coded class archetypes becomes helpful in the analysis of requirements and a problem domain. The class archetypes themselves represent concepts that are within the grasp of most reasonably intelligent people even if they do not have a technical or analytical background. Also most people find learning a four-colour code well within their grasp. With colour, object models become a better communication framework for business and development to collaboratively explore and explain requirements for software systems and components.

Secondly, for developers, the use of colour adds new depth to a diagram making the different layers of information in it stand out from each other.

Why is this so? I readily acknowledge that I am not an expert in the psychological and technological aspects of the use of colour but a quick browse of the Internet reveals a wealth of information about colour theory, models, and psychology both ancient and modern. Thanks must go to the authors of the many helpful websites, too many to list individually, that were visited in researching this topic.

Some developers talk of poorly designed or written code as having a bad smell. Peter Coad used to talk of good object models singing to him, and many of us have used the expression, "it just feels right" to justify an analysis or design decision. What we are all talking about is a sense of harmony. Harmony can be defined as a pleasing arrangement of parts, whether it is music, poetry, source code or colour. Harmony has a sense of correctness, order and balance. Visually, harmony is something that is pleasing to the eye. The opposite of harmony is discord. Visual discord occurs when something is either boring or chaotic. The careful use of colour helps a viewer engage. Poor use of colour can cause a viewer to disengage. Unexpected or unusual combinations or patterns of colour catch the eye.

Before you start to read the detailed textual content of a colour-coded object model, the overall shape and colour are already communicating high-level information. Colour makes the patterns of collaborating class archetypes visible from a distance. Potential problems appear as areas of discord within those patterns. Colour also provides an 'easy in' for non-technical people or those that are not so familiar with UML notation; it gives them something conceptually simple and tangible that they can grasp immediately rather than the featureless, flatness of a monochrome diagram. This helps people penetrate through the initial discouraging and often overwhelming 'where do I start?' feelings when presented with a complex class or sequence diagram.

In the same way that once you have watched colour television or seen colour photographs you do not want to return to black and white except for nostalgic reasons, most people once they have experienced object modeling in colour never want to return to the shallowness of the black and white version.

Four Colours for Four Archetypes

With four archetypes we obviously need four colours but which four and which archetype should be assigned which colour? We used the four colours we had immediately available in Singapore but are there better choices or good alternatives especially when those colours are not available?

Throughout history various philosophers, psychologists and scientists from China, India, Ancient Greece and Europe including Pythagoras and Leonardo De Vinci have proposed different sets of primary colours; those colours that can be mixed to form all other colours. These historical models were largely based on perception and often associated with the known planets of the solar system and the historical elements of earth, water, wind, and fire. In addition to black and white, the popular choices were red, green, blue and yellow. These same six colours now form the Natural Colour System, the most widely used colour notation system in Europe (www.ncscolour.com)

Perhaps predictably, the Post It notes originally used in the modelling exercise in Singapore were pastel shades of red (pink), green, blue, and yellow. Being variations of the perceived primary colours, the pastel shades contrast well with each other so that they stand out but are not so bright that they overpower or so dark that it becomes difficult to read text written or printed on them.

So we have a set of four ideal colours:

  1. Pink
  2. Pastel Yellow
  3. Pastel Green
  4. Pastel Blue

Unfortunately for those wanting to use the workshop-style modeling sessions with Post-It notes it is becoming harder and harder to find packs of Post-It notes in these four colours. I often need to substitute one or more colours. In these situations I find purple or mauve makes a passable substitute for blue, pastel orange for pink, and grey for green. I have not found a great substitute for yellow but because it is the original Post-It note colour I have always found it to be readily available. As with any notation, it is takes some effort to switch so it is best to stick with a set of colours for the duration of a modeling exercise if at all possible. Whenever I can I use the original four colours.

Choosing the Colour for each Archetype

So we have four colours but which colour should be assigned to which class archetype?

Red, orange and yellow are thought of as warm, active, and dynamic colours. Green, purple and blue are thought of as cooler, passive, and more stable. Lighter colours are also thought of as being more active than deeper colours.

These ideas fit nicely with the moment-intervals being pink because moment-intervals represent some event or activity, some sort of interaction. They represent where the money is made and spent in a business system and that is something that excites business people. Selecting orange as alternative colour to pink also makes sense for the same reasons.

With roles there is also a sense of activity because they represent the ways people, places and things participate in moment-intervals. Therefore, making roles yellow, the next warmest colour in our selection makes sense.

The most passive and stable objects in our problem domain are those of the description classes and therefore it is appropriate to colour these blue. Purple as an alternative to blue again fits nicely.

That leaves green for the relatively stable entities, the people, places and things. Gray also fits as an alternative colour for this archetype.

class archetypes

Figure 3: The four achetypes in their assigned colours

More on moment-intervals...
More on Roles...
More on Descriptions ...
More on Party, Places and Things...

More on...



Copyright © 2008 Stephen R Palmer. All rights reserved.