Section 4.2. Getting Started with Classes in UML


4.2. Getting Started with Classes in UML

So far we've been looking at what a class is and how it enables the key benefits of the object-oriented approach of system development: abstraction and encapsulation. Now it's time to take a look at how classes are represented in UML.

At its simplest, a class in UML is drawn as a rectangle split into up to three sections. The top section contains the name of the class, the middle section contains the attributes or information that the class contains, and the final section contains the operations that represent the behavior that the class exhibits. The attributes and operations sections are optional, as shown in Figure 4-4. If the attributes and operations sections are not shown, it does not necessarily imply that they are empty, just that the diagram is perhaps easier to understand with that information hidden.

Figure 4-4. Four different ways of showing a class using UML notation


A class's name establishes a type for the objects that will be instantiated based on it. Figure 4-5 shows a couple of classes from the CMS in Chapter 2: the BlogAccount class defines the information that the system will hold relating to each of the user's accounts, and the BlogEntry class defines the information contained within an entry made by a user into her blog.

Figure 4-5. Two classes of objects have been identified in the CMS


The interaction diagrams covered in Chapters 7 through 10 are used to show how class instances, or objects, work together when a system is running.




Learning UML 2.0
Learning UML 2.0
ISBN: 0596009828
EAN: 2147483647
Year: 2007
Pages: 175

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net