Software Engineering – Design Class Diagrams

Design / Object Classes

A Design Class diagram is a way of modelling the domain to a level of detail much more than that of a domain model. Inside a design class diagram, the classes become objects – Object Classes:

Objects are created according to an Object Class Definition. An Object Class definition is both a type and a template for creating objects. It includes declarations of all the attributes and operations that should be associated with an object of that class.

Ian Sommerville- Software Engineering Edition 8, 2007- Page 316, Ch 14.1

In UML an object class is represented as a named rectangle with 2 sections – the object attributes and the object operations. An example of this is shown below using an object class that models a Circle / Rectangle and a Student:

CircleOC RectangleOC


If one was to thing of this in an Object Oriented way, then the top section would be the declaration of variables, and the bottom section the functions/methods.


Design Class Diagram Example

Now, this is going to get bog, fast – just a warning, hehe. Now for this part, you will need to read this:

An exam contains 3 different types of questions:

  1. Plain text questions
  2. Multiple choice questions
  3. Composite questions

Using this, draw a Domain Model and then a Design Class Diagram for that Domain.

First things first is that we need to identify the Classes. Well, quite obviously we have 3 Classes straight of the top:

  1. Plain text questions
  2. Multiple Choice questions
  3. Composite questions

BUT, look more closely… what do you see? Well, if you saw it or not, they all inherit something  – that’s right, they all inherit “Question”, think about it, each one will contain something of the same variables and operations etc etc, and we really don’t want to write out the same variable/operation declaration 3 times?!

But then.. what about Multiple Choice questions? They contain multiple answers, so surely we need a type for that – so we could use “Multiple Choice Question Options”

That means we now have 5 classes! :

  1. Questions
    1. Plain Text
    2. Composite
    3. Multiple Choice
      1. Multiple Choice Option


So for quick guidance, here is what the Domain Model will look like:


Here, Plain Text, Multiple Choice and Composite all inherit Question. Aside from this Multiple Choice Questions contains Multiple Choice Options; and Composite Questions contain more Questions.

Note: (A) here means that “Question” is Abstract

Extra Features

hmmm… I just realised, i missed something up above – im sooo sorry 😦

So, yeah, there are some extra features inside of a Design Class Diagram – besides the bleeding obvious… These extra features i forgot to mention are:

  • Visibilities. The variables and operations all have visibilities, these are:
      • + (public)
      • – (private)
      • # (protected)
      • ~ (package)

I think that’s it… if it isn’t than either leave a comment, email me or if your at my uni then just come bother me, hahaha 😀


Design Class Diagram Example – Finally…

OK, so here we go! Using the Domain Model up above, here is the Design Class Diagram for that Domain Model! :



This all looks good, but take a look at Plain Text and Multiple Choice. They both have a field called “+marksAllocated: int”. So we could refactor some here and make the diagram a little neater:


**If you see a spelling error, it will more than likely be “Reactor” – stupid Windows Live Blogger making the word “Refactor” into “Reactor”  😦


About Badgerati
Computer Scientist, Games Developer, and DevOps Engineer. Fantasy and Sci-fi book lover, also founder of Cadaeic Studios.

One Response to Software Engineering – Design Class Diagrams

  1. Pingback: Software Engineering – The Class Model « Computer Science: Source

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: