PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 6 ■ OBJECTS AND DESIGN

The class is divided into three sections, with the name displayed in the first. These dividing lines are
optional when we present no more information than the class name. In designing a class diagram, we
may find that the level of detail in Figure 6–1 is enough for some classes. We are not obligated to
represent every field and method, or even every class in a class diagram.
Abstract classes are represented either by italicizing the class name, as in Figure 6–2, or by adding
{abstract} to the class name, as in Figure 6–3. The first method is the more common of the two, but the
second is more useful when you are making notes.


■Note The {abstract} syntax is an example of a constraint. Constraints are used in class diagrams to describe


the way in which specific elements should be used. There is no special structure for the text between the braces;


it should simply provide a short clarification of any conditions that may apply to the element.


Figure 6–2. An abstract class


Figure 6–3. An abstract class defined using a constraint


Interfaces are defined in the same way as classes, except that they must include a stereotype (that is,
an extension to the UML), as in Figure 6–4.


Figure 6–4. An interface


Attributes


Broadly speaking, attributes describe a class’s properties. Attributes are listed in the section directly
beneath the class name, as in Figure 6–5.


Figure 6–5. An attribute

Free download pdf