Chapter 3 Building Structural Diagrams
An attribute is a named property of a class (or an interface) describing its characteristics.
An attribute can be created for a class or interface in the following diagrams:
A class or an interface may have none or several attributes. Each object in a class has the same attributes, but the values of the attributes may be different.
Attribute names within a class must be unique. You can give identical names to two or more attributes only if they exist in different classes.
In the following example, the class Printer contains two attributes: printspeed and laser:
An attribute of an interface is slightly different from an attribute of a class because an interface can only have constant attributes (static and frozen). For example, consider an interface named Color with three attributes RED, GREEN, and BLUE. They are all static, final and frozen.
If you generate in Java, you see:
public interface Color { public static final int RED = 0xFF0000; public static final int GREEN = 0x00FF00; public static final int BLUE = 0x0000FF; }
All these attributes are constants because they are static (independent from the instances), final (they can not be overloaded), and frozen (their value cannot be changed).
You can use the attributes of other interfaces or classes and add them to the current interface.
Copyright (C) 2006. Sybase Inc. All rights reserved. |