5. Class diagram

class diagram

This is a class diagram. The name of the class is shown within the top box. The other boxes are optional as they show more details about the class itself.

A number of class diagrams joined together show how the system is put together.

If you were using UML to show how 'train journey' fits within a larger system then you may decide to not show the extra detail. In this way UML is able to show the appropriate level of detail depending on the purpose of the diagram.

The middle box shows the attributes of the class i.e. the data stored within the class that help define its nature. An attribute takes the form

attribute : attribute type

The first attribute in this example is Starting_from and it is of type 'text'.

The second box shows the class operations (methods) that process data and that also set and get their values. An operation may need a parameter. These are shown within the brackets along with the data type of the attribute.

For example the Set_start method expects a text parameter that defines the location of the start point. Note that the word 'in' or 'out' is optional, indeed with modern languages such as C++ you would not normally use them. They are handy if you intend to use an older language such as FORTRAN to implement the software to indicate whether the parameter is an input or an output.

A method can optionally include a symbol in front of it to indicate the scope of the method. For example, + means public, - means private, # means protected, ~ means package.

In the example the Get_journey() method could be shown as +Get_journey() to indicate that it is a public method.


Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: UML class diagram




Copyright © www.teach-ict.com