Software Engineering for Students A Programming Approach
Software Engineering for Students A Programming Approach Software Engineering for Students A Programming Approach
C.2 ● Class diagrams C.2 Class diagrams 413 These describe classes and their interrelationships. Classes are shown as rectangles containing the class name. The simplest relationship is where a class uses another. For example, in Figure C.2, class Game uses classes Defender, Alien, Laser and Bomb. This means that Game creates objects from these classes and/or calls methods in objects created from these classes. A class diagram can also show the inheritance relationships between classes – the subclasses and superclasses. As illustrated in Figure C.3, to show that a class extends another, a line is drawn from the subclass to the superclass, with the arrowhead pointing to the superclass. Thus Sprite is the superclass of both Alien and Bomb. If a class is an abstract class, the name of the class is written in italics. This can be difficult to see, particularly when hand-written. So the name of an abstract class can be followed by the text {abstract} to clarify the meaning. An interface is described in the same way as a class – as a box. The difference is that the text precedes the name. A class that implements an interface has a dashed line with an arrow leading to the interface box (see Figure C.4). A class can be described in more detail, as illustrated in Figure C.5. There are three compartments in this type of class diagram. The first compartment holds the class Figure C.2 Class diagram Game Figure C.3 Class diagram showing inheritance Sprite Defender Alien Laser Bomb Alien Bomb
414 Appendix C ■ UML summary name, the second describes variables and the third describes methods. Any class (static) variables or methods are shown underlined. The visibility of an element can, optionally, be described in a prefix as in Java – public, private, protected or default. In keeping with information hiding, the diagram is often drawn with the second compartment (the variables) omitted. C.3 ● Package diagrams A package can be diagrammed as shown in Figure C.6. It is a rectangle with a tab at the top that holds the package name. Optionally, the classes within a package can be shown within the rectangle. This shows a class util that consists of classes Random, ArrayList and Stack. C.4 ● Activity diagrams StackInterface Stack Figure C.4 A class and its interface. The arrow should be hollow Game panel timer mouseMoved mouseClicked actionPerformed Figure C.5 Class diagram showing the detail of a class An activity diagram describes a sequence of activities. Thus an activity diagram can be used to show the flow of control through software. An activity diagram can show: ■ conditions (corresponding to if statements) ■ loops (corresponding to for and while statements) ■ concurrent activity (corresponding to threads).
- Page 385 and 386: 362 Chapter 29 ■ Software metrics
- Page 387 and 388: 364 Chapter 29 ■ Software metrics
- Page 389 and 390: 366 Chapter 29 ■ Software metrics
- Page 391 and 392: 368 Chapter 29 ■ Software metrics
- Page 393 and 394: CHAPTER 30 This chapter: 30.1 ● I
- Page 395 and 396: 372 Chapter 30 ■ Project manageme
- Page 397 and 398: 374 Chapter 30 ■ Project manageme
- Page 399 and 400: 376 Chapter 30 ■ Project manageme
- Page 401 and 402: 378 Chapter 30 ■ Project manageme
- Page 403 and 404: 380 Chapter 30 ■ Project manageme
- Page 405 and 406: 382 Chapter 30 ■ Project manageme
- Page 408 and 409: CHAPTER 31 This chapter: 31.1 ● I
- Page 410 and 411: 31.3 Case study - assessing verific
- Page 412 and 413: 31.5 A single development method? 3
- Page 414 and 415: Further reading 391 31.2 Draw up a
- Page 416 and 417: 32.3 ● The world of programming l
- Page 418 and 419: 32.5 ● The real world of software
- Page 420 and 421: 32.6 Control versus skill 397 Final
- Page 422 and 423: Formal methods 32.7 Future methods
- Page 424 and 425: Summary 401 In the short-term futur
- Page 426: Further reading 403 An extensive tr
- Page 430 and 431: APPENDIX A Case studies are used th
- Page 432 and 433: Figure A.1 Cyberspace invaders A.4
- Page 434 and 435: APPENDIX B Glossary Within the fiel
- Page 438 and 439: util Figure C.6 A package diagram S
- Page 440 and 441: References to books and websites ar
- Page 442 and 443: abstraction 99, 107 acceptance test
- Page 444 and 445: fork 324 formal methods 276, 388, 3
- Page 446 and 447: quality 18, 362 quality assurance 1
414 Appendix C ■ UML summary<br />
name, the second describes variables and the third describes methods. Any class (static)<br />
variables or methods are shown underlined. The visibility of an element can, optionally,<br />
be described in a prefix as in Java – public, private, protected or default.<br />
In keeping with in<strong>for</strong>mation hiding, the diagram is often drawn with the second<br />
compartment (the variables) omitted.<br />
C.3 ● Package diagrams<br />
A package can be diagrammed as shown in Figure C.6. It is a rectangle with a tab at<br />
the top that holds the package name. Optionally, the classes within a package can be<br />
shown within the rectangle. This shows a class util that consists of classes Random,<br />
ArrayList and Stack.<br />
C.4 ● Activity diagrams<br />
<br />
StackInterface<br />
Stack<br />
Figure C.4 A class and its interface. The arrow should be hollow<br />
Game<br />
panel<br />
timer<br />
mouseMoved<br />
mouseClicked<br />
actionPer<strong>for</strong>med<br />
Figure C.5 Class diagram showing the detail of a class<br />
An activity diagram describes a sequence of activities. Thus an activity diagram can be<br />
used to show the flow of control through software. An activity diagram can show:<br />
■ conditions (corresponding to if statements)<br />
■ loops (corresponding to <strong>for</strong> and while statements)<br />
■ concurrent activity (corresponding to threads).