PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 6 ■ OBJECTS AND DESIGN

Sequence Diagrams


A sequence diagram is object based rather than class based. It is used to model a process in a system
step by step.
Let’s build up a simple diagram, modeling the means by which a Report object writes product data.
A sequence diagram presents the participants of a system from left to right, as in Figure 6–18.


Figure 6–18. Objects in a sequence diagram


I have labeled my objects with class names alone. If I had more than one instance of the same class
working independently in my diagram, I would include an object name using the format label:class
(product1:ShopProduct, for example).
You show the lifetime of the process you are modeling from top to bottom, as in Figure 6–19.


Figure 6–19. Object lifelines in a sequence diagram


The vertical broken lines represent the lifetime of the objects in the system. The larger boxes that
follow the lifelines represent the focus of a process. If you read Figure 6–19 from top to bottom, you can
see how the process moves among objects in the system. This is hard to read without showing the
messages that are passed between the objects. I add these in Figure 6–20.
The arrows represent the messages sent from one object to another. Return values are often left
implicit (though they can be represented by a broken line, passing from the invoked object to the

Free download pdf