tall bailey button uggs UML Class Diagrams
You will have noticed that in most of the explanations so far, all of the classes have been shown with a particular form of diagram. These are known as UML (Unified Modelling Language) diagrams. These have a particular syntax and set of symbols, each of which denote different kinds of information and behaviour.
UML has specific syntax for both the items inside of a class, and the relationships between classes. There is more to UML syntax than this brief summary; however these are the most important points to remember.
UML is language inspecific, however some languages have features that others lack. For (mainly) this reason, it’s not uncommon to see minor deviations of the UML spec used by some programmers and system designers that are tailored more to their purposes.
This can sometimes make UML diagrams somewhat difficult to understand completely.
Attributes and Methods
Classes are made up of two kinds of attributes; variables and methods. These attributes share some notation forms (for example, listing a variable, or declaring visibility or behavioural modifiers), and some are unique (for example, a method’s return type.)Visibility
The visibility is shown with a single character;The difference between association, aggregation and composition is confusing, and often the latter two terms are used interchangably. They mean something similar, but to different extents.
Assocation: there is some form of relationship where one class uses the services of another. For example,
an timekeeper uses a watch, but the watch may not be an intrinsic attribute of the timekeeper.
Aggregation: an item is comprised of another, and when you destroy the “whole”, it doesn’t also destroy the aggregated “parts”. For example, a Business is an aggregation of People, as a business is comprised of employees. However, if the business goes bankrupt and is dissolved, the people don’t get destroyed along with it.
Composition: an item is made up of another, in the sense of being a container. A “part” can only belong to one “whole” at a time. For example, a cookie jar is composed of cookies; no one cookie can be in two jars at the same time, and if you throw the cookie jar in the bin, the cookies inside get thrown out with it.
Practically speaking, the most important thing is identifying that there is a relationship between classes; don’t get too caught up in trying to be completely specific and taking a long time trying to determine the exact kind of association that is present.
UML Diagram Example
The diagram below is a diagram describing the relationships inherent in a small phone book manager program.
There is a standard phone number record, which is extended to a business number record. The driver class holds an instance of a data structure (which implements an interface specifying how it should interoperate),
and creates phone number record objects for storing into this structure.