针对 java程序员的 u m l概述

247
UML for Java Programmers 中文共享版 (正式中文共享版 Ver 1.0) [重要说明:本文档目前是我们快速完成的草稿版,肯定存在一些翻译问题,请 各位阅读过的兄弟能够帮我们指出存在的问题,这将是对我们的工作的最大支 持!有任何建议和问题请登陆http://www.Matrix.org.cn 论坛讨论!请随时关注 Matrix获得最新版本和其他翻译书籍] 原著:Robert Cecil Martin 翻译:Wanghaibo; Melthaw Zhang; Orient Sun; LishiFeng http://www.Matrix.org.cn 注明:本资料由 Wanghaibo Melthaw Zhang 等负责翻译并授权 Matrix (http://www.Matrix.org.cn )发布,您可以免费使用和任意传播,但是您必须遵循以下条款: 1.不得用于任何商业目的,包括但不仅限于出版,印刷,销售,咨询。 2.您可以传播本资料,但是传播必须保留本协议说明并不可做任何修改。 3.不得对本文内容进行修改再传播,为了保证文章内容和版本的统一,任何修改建议请在 Matrix 论坛讨论,并由 Matrix 组织统一修改,修改后统一发布修改过后的版本。 4Matrix 对本授权协议拥有最终解释权。 5.与本书相关的所有公告都发布在MatirxUml论坛 Chris ([email protected]) From Matrix

Upload: shilong-sang

Post on 12-Nov-2014

4.293 views

Category:

Technology


4 download

DESCRIPTION

 

TRANSCRIPT

  • 1. UML for Java Programmers ( Ver 1.0) [ http://www.Matrix.org.cn! Matrix] Robert Cecil Martin Wanghaibo; Melthaw Zhang; Orient Sun; LishiFeng http://www.Matrix.org.cn Wanghaibo Melthaw Zhang Matrix (http://www.Matrix.org.cn) 1 2 3 Matrix Matrix 4Matrix 5MatirxUml Chris ([email protected]) From Matrix
  • 2. Matrix- Java (http://www.Matrix.org.cn) NO: 1 2004-4-7 2004-4-10 Wanghaibo Ver 0.4 2 2004-4-16 2004-4-16 Wanghaibo Ver 0.5 3 2004-4-18 2004-4-18 Wanghaibo Ver 0.51 4 2004-4-19 2004-4-28 Melthaw Zhang Ver 0.6 5 2004-4-19 2004-4-29 Wanghaibo Ver 0.7 6 2004-4-19 2004-5-12 Orient Sun Ver 0.8 7 2004-4-19 2004-5-12 LishiFeng Ver 0.8 8 2004-5-1 2004-5-13 Melthaw Zhang Ver 0.9 9 2004-9-14 2004-9-15 Wanghaibo Ver 1.0 2004-10-1 10 2004-10-1 Melthaw Zhang Ver 1.1 5 Matrix IT UML for Java Programmers [ ]Matrix []Matrix- []Oracle Matrix Java [New]Matrix Jmatrix 2 247
  • 3. Matrix- Java (http://www.Matrix.org.cn) Java UML ............................................................................. 10 .....................................................................................................11 (Class Diagram)..................................................................................11 (Object Diagram) ........................................................................... 13 (sequence diagram)........................................................................ 14 (collaboration diagram)............................................................... 15 State Diagrams........................................................................ 15 .................................................................................................................. 16 ........................................................................................................... 16 (Diagrams) ............................................................................................. 17 ................................................................................................. 17 .................................................................................. 17 ....................................... 18 UML ............................................................................................... 18 ............................................................................................. 18 ................................................................................................. 21 ............................................................................... 22 ........................................................................................................... 22 (Behavior).................................................................................... 22 .................................................................................................... 24 ............................................................................... 26 .................................................................................................... 27 ........................................................................................................... 27 ......................................................................................... 28 UML ........................................................... 28 Case .................................................................................................. 29 ............................................................................................. 29 Javadocs ............................................................................................... 30 .................................................................................................................. 30 3 247
  • 4. Matrix- Java (http://www.Matrix.org.cn) (Class) ...................................................................................................... 32 ........................................................................................................... 32 ............................................................................................................... 32 ........................................................................................................... 33 ........................................................................................................ 33 ........................................................................................................... 33 ................................................................................................. 35 .................................................................................................................. 36 ................................................................................................. 36 ........................................................................................................ 37 ........................................................................................................... 38 ........................................................................................................... 38 ........................................................................................................... 39 ........................................................................................................ 40 ................................................................................................. 41 ........................................................................................................ 42 ................................................................................................. 42 ........................................................................................................ 43 ................................................................................................. 44 .................................................................................................................. 44 ........................................................................................................... 44 (Sequence) ............................................................................................. 45 .................................................................................................................. 45 .................................................................................. 45 ................................................................................................. 46 ................................................................................................. 47 ................................................................................................. 48 ........................................................................................................... 50 ................................................................................................. 50 ............................................................................................. 52 4 247
  • 5. Matrix- Java (http://www.Matrix.org.cn) .................................................................................................... 53 ........................................................................................................ 55 .................................................................................................... 56 ......................................................................................... 57 .................................................................................................................. 58 (use case)................................................................................................. 59 ........................................................................................................... 59 ................................................................................................. 59 .................................................................................................... 60 .................................................................................................... 60 ........................................................................................................... 61 ............................................................................................................... 61 ................................................................................................. 61 .................................................................................................... 62 .................................................................................................................. 62 OOD................................................................................. 63 ........................................................................................................... 63 ............................................................................................. 63 ............................................................................................. 64 SRP...................................................................................... 64 -OCP .................................................................................... 66 Liskov (LSP) ....................................................................................... 79 (DIP)..................................................................................... 81 ISP ....................................................................................... 81 .................................................................................................................. 83 ........................................................................................................... 83 dX 85 ........................................................................................................... 85 .................................................................................................... 85 ............................................................................................. 86 5 247
  • 6. Matrix- Java (http://www.Matrix.org.cn) ........................................................................................................... 86 .................................................................................................................. 87 .................................................................................................... 87 .................................................................................................... 87 ........................................................................................................... 88 .................................................................................................... 88 .................................................................................. 89 .................................................................................. 89 .................................................................................................... 89 ................................................................................................. 90 .................................................................................................... 90 ........................................................................................................... 91 ......................................................................................... 91 .................................................................................................... 91 .................................................................................................................. 92 ........................................................................................................... 92 (Packages) .................................................................................................... 94 Java Packages ................................................................................................. 94 Packages................................................................................................... 94 Dependencies ............................................................................. 95 .jar Binary Components ................................................... 95 Principles of Package Design............................................... 96 /The Release/Reuse Equivalency Principle (REP) 96 The Common Closure Principle (CCP)......................... 97 The Common Reuse Principle (CRP)........................... 97 The Acyclic Dependencies Principle (ADP) .............. 97 The Stable Dependencies Principle (SDP)................... 97 The Stable Abstractions Principle (SAP) ...................... 98 .................................................................................................................. 99 Object Diagrams ........................................................................... 100 6 247
  • 7. Matrix- Java (http://www.Matrix.org.cn) ................................................................................................................ 100 Active Objects ........................................................................... 101 ................................................................................................................ 104 (State Diagrams) .................................................................................. 105 ......................................................................................................... 105 .................................................................................................. 106 ...................................................................................................... 107 ......................................................................... 109 ....................................................................................... 109 SMC..........................................................................................................110 ICE..........................................................................................113 .................................................................................................................118 .....................................................................................................119 Mark IV ..........................................................................................119 .................................................................................................. 122 ........................................................................................... 123 .................................................................................................. 123 ......................................................................................................... 124 ...................................................................................................... 124 ......................................................................................................... 125 ........................................................................................... 126 ...................................................................................................... 126 .................................................................................... 127 Use Case 1: ......................................................... 127 Use Case 2: Containment Vessel ......................................... 128 Use Case 3:............................................................................... 129 Use Case 4:............................................................................... 130 ........................................................................................... 131 Use Case 1.(Mark IV) .......................................... 131 isReady() .................................................................................. 133 7 247
  • 8. Matrix- Java (http://www.Matrix.org.cn) start() ........................................................................................ 134 M4UserInterface.checkButton .................................... 135 ............................................................................................... 136 ....................................................................................... 137 ......................................................................... 138 SMC ............................................................................. 151 ................................................................................ 151 ......................................................................................................... 151 SMCRemote ........................................................................................... 152 SMCRemoteClient .......................................................................................... 152 SMCRemoteClient (SMCRemoteClient Command Line) ............. 152 SMCRemote ............................................................................. 153 SMCRemoteClient ................................................................................... 154 (Loggers) .......................................................................................... 161 The Remote Sessions. ............................................................................ 162 RemoteSessionBase ............................................................................... 163 .................................................................................................. 167 ............................................................................................... 170 FileCarrier ............................................................................. 176 SMCRemoteClient .......................................................................... 178 SMCRemoteServer......................................................................................... 178 SocketService.......................................................................................... 178 SMCRemoteService ................................................................................ 183 SMCRemoteServer.................................................................................. 189 ServerSession ......................................................................................... 192 Three Level FSM ..................................................................................... 194 (UserRepository).................................................................... 203 (OReillyEmailSender) ............................................................ 206 (PasswordGenerator) ............................................................ 207 ................................................................................................................ 208 8 247
  • 9. Matrix- Java (http://www.Matrix.org.cn) SMCRemoteClient ........................................................................... 208 SocketService .................................................................................. 217 SMCRemoteServer ......................................................................... 220 .................................................................................................. 233 ServerController (SMC ) .......................................................................... 237 ......................................................................................................... 246 9 247
  • 10. UML for Java Programmers Matrix(http://www.matrix.org.cn) Java UML UML(notation) Fowler IT ConceptualSpecificationImplementation (Dog)(Animal) UML Figure 1-1 (generalization) Animal Dog Animal Dog Dog Animal Sparky 10 247
  • 11. UML for Java Programmers Matrix(http://www.matrix.org.cn) Animal Dog UML UML UML UML (static diagrams) (Dynamic diagrams) (Physical diagrams) Listing 1-1 (Class Diagram) Figure 1-2 (Class Diagram) Listing 1-1 TreeMap add get TreeMap TreeMapNode topName reference TreeMapNode TreeMapNode -- nodes TreeMapNode itsKey itsKey itsKey Comparable itsValue 11 247
  • 12. UML for Java Programmers Matrix(http://www.matrix.org.cn) (associations) 12 247
  • 13. UML for Java Programmers Matrix(http://www.matrix.org.cn) 1 interface Comparable (interface) Listing 1-1 TreeMap TreeMapNode topNode TreeMap topNode (Object Diagram) Figure 1-3 (Object Diagram) (snapshot) itsKey (links) Figure 1-3 nodes 13 247
  • 14. UML for Java Programmers Matrix(http://www.matrix.org.cn) (sequence diagram) Figure 1-4 (sequence diagram) TreeMap.add TreeMap add topNode (null) TreeMap TreeMapNode topNode TreeMap add topNode (guards) TreeMapNode (construction) 14 247
  • 15. UML for Java Programmers Matrix(http://www.matrix.org.cn) (data tokens) TreeMap activation add (collaboration diagram) Figure 1-5 (collaboration diagram) treeNode TreeMap.add (links) TreeMap.add 1 TreeMapNode.add 1.1 1.1 1 State Diagrams UML (finite state machines)Figure 1-6 Figure 1-6 Locked UnLocked coin pass 15 247
  • 16. UML for Java Programmers Matrix(http://www.matrix.org.cn) (transitions) Figure 1-6 Locked coin Unlocked Unlock Unlocked pass Locked Lock Unlocked coin Unlocked Thankyou Locked pass Locked Alarm UML [Fowler00]: UML Distilled, 2d. ed. Martin Fowler, Addison Wesley, 199? 16 247
  • 17. UML for Java Programmers Matrix(http://www.matrix.org.cn) (Diagrams) UML UML UML (models) UML UML UML UML UML UML UML UML UML 17 247
  • 18. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML UML UML UML UML UML UML UML UML UML Figure 2-1 LogiServlet Servlet UserDatabase LoginServlet HTTPRequest HTTPResponse UML Listing-2-1 UML 18 247
  • 19. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 2-2 Figure 2-3 UML 19 247
  • 20. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML (roadmaps) 20 247
  • 21. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 2-4 Space Polyline Polyline LinearObject Lines LinearObject Points UML UML (Figure 2-5) 21 247
  • 22. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML Case UML Web UML ! UML (Behavior) UML 22 247
  • 23. UML for Java Programmers Matrix(http://www.matrix.org.cn) Button Dialler Button digit Dialler Dialler digit displayDigit Screen Dialler tone Speaker 23 247
  • 24. UML for Java Programmers Matrix(http://www.matrix.org.cn) Radio Screen () Figure 2-6 (class)(association) UML (aggregation) (composition)(relationships) 24 247
  • 25. UML for Java Programmers Matrix(http://www.matrix.org.cn) Button Dialler Button Dialler Button Button Button Dialler Button Button Dialler (interface) Figure 2-8 Button (token) Button ButtonListener buttonPressed Button Dialler Button Figure 2-6 Dialler Button Dailler ButtonListener buttonPressed Dialler Button 25 247
  • 26. UML for Java Programmers Matrix(http://www.matrix.org.cn) ButtonDiallerAdapter ButtonListener buttonPress digit(n) Dialler digit Dialler ButtonDiallerAdapter Listing 2-2 26 247
  • 27. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 2-9 Figure 2-6 Figure 2-10 5 5 UML UML 27 247
  • 28. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML UML UML UML 28 247
  • 29. UML for Java Programmers Matrix(http://www.matrix.org.cn) Case UML Case UML case UML case UML case UML UML case IDE IDE CASE Cool UML IDE Case Case 29 247
  • 30. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML 12 100 Java 25 200 UML ER wiki Javadocs Javadocs Javadocs UML 5 UML Case UML case IDE UML Case UML 30 247
  • 31. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML 31 247
  • 32. UML for Java Programmers Matrix(http://www.matrix.org.cn) (Class) UML Figure 3-1 Dialler Figure 3-2 - private#(protected) + (public) 32 247
  • 33. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML Figure 3-3 Phone Button Phone Button Figure 3-3 15 button Phone Figure 3-4 PhoneBook PhoneNumber (*) Java Vector List HasA has Phonebook PhoneNumbers Hasa IsA 6 UML Figure 3-5 Employee 33 247
  • 34. UML for Java Programmers Matrix(http://www.matrix.org.cn) (inheritance) UML SalariedEmployee Emplyee Employee UML (base class) UML Java Java Figure 3-6 Figure 3-7 COM 34 247
  • 35. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 3-8 ATM WithdrawTransaction CashDispenser CashDispenser UI WithDrawlUI PromptForAccount informCashDispenserEmpty 35 247
  • 36. UML for Java Programmers Matrix(http://www.matrix.org.cn) UI UI UI Listing 3-1 UML Figure 3-8 interfaceinterface java utility interface interface java Figure 3-9 36 247
  • 37. UML for Java Programmers Matrix(http://www.matrix.org.cn) utilityutilityBooch Figure 3-10 persistentC-APIstruct function UML {abstract} Figure 3-11 {abstract} Figure 3-12 UML 37 247
  • 38. UML for Java Programmers Matrix(http://www.matrix.org.cn) {abstract} {author=Martin, date=20020429, file=shape.java, private} UML {abstract} UML java boolean (true){abstract} {abstract=true} Figure 3-13 {abstract} UML /whole/partFigure 3-14 Figure 3-14 38 247
  • 39. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML UML Figure 3-15 Figure 3-16 UML Java C++ (owner) (ward)UML Figure 3-17 39 247
  • 40. UML for Java Programmers Matrix(http://www.matrix.org.cn) Java java Figure 3-18 Address Address String Address Address String UML (multipicity) Figure 3-19 BinaryTreeNode 2 * 0..* 0 0 1 Java 0..1 1 1..* 3 5 3..5 40 247
  • 41. UML for Java Programmers Matrix(http://www.matrix.org.cn) 0,2..5,9..* Figure 3-20 UML creates (factory) local 41 247
  • 42. UML for Java Programmers Matrix(http://www.matrix.org.cn) parameter delegates UML PROXY DECORATOR COMPOSITE7 UML Java UML Figure 3-22 42 247
  • 43. UML for Java Programmers Matrix(http://www.matrix.org.cn) anonymous Figure 3-23 Java weaksoft phantom Figure 3-24 Figure 2-25 43 247
  • 44. UML for Java Programmers Matrix(http://www.matrix.org.cn) Java Figure 3-26 LoginServlet Employee empid Employee UML UML UML UML UML [Booch94]: Object Oriented Analysis and Design with Applications, Grady Booch, Benjamin Cummings, 1994 [GOF94]: Design Patterns, Gamma, Helm, Vlissides, Johnson, Addison Wesley, 1994 44 247
  • 45. UML for Java Programmers Matrix(http://www.matrix.org.cn) (Sequence) UML UML 1978 James Grenning Figure 4-1 (lifelines) 45 247
  • 46. UML for Java Programmers Matrix(http://www.matrix.org.cn) (data tokens) (Time) LoginServlet (Activation) login login login getEmployee e getEmployee Employee egetEmployee Employee EmployeeDB getEmployee EmployeeDB Listing 4-1 Figure 4-2 ShapeFactory Listing 4-2 46 247
  • 47. UML for Java Programmers Matrix(http://www.matrix.org.cn) Java Figure 4-3 UML XX Listing 4-3 clear topNode (nil) TreeMap TreeNode UML Figure 4-4 47 247
  • 48. UML for Java Programmers Matrix(http://www.matrix.org.cn) 48 247
  • 49. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 4-5 UML Listing 4-4 Payroll Figure 4-5 Figure 4-6 Figure 4-6 49 247
  • 50. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 4-7 Figure 4-8 50 247
  • 51. UML for Java Programmers Matrix(http://www.matrix.org.cn) (loop) if payEmployee *[while id := idList.next()] (guard) false UML java payEmployee payEmploy [payday] if ifPayDay true CalculatePay,CalculateDedutions sendPayment UML (clunky?) Listing 4-4 51 247
  • 52. UML for Java Programmers Matrix(http://www.matrix.org.cn) OO Figure 4-9 caller callee telco (off hook) received dial tone (ringing)(playing ringback) Figure 4-10 52 247
  • 53. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 4-10 (race condition) (asychronous message) Figure 4-11 UML 53 247
  • 54. UML for Java Programmers Matrix(http://www.matrix.org.cn) Listing 4-5 listing 4-6 Figure 4-11 Listing 4-5 Listing 4-6 Log logMessage LogText logMessage 54 247
  • 55. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML Figure 4-12 55 247
  • 56. UML for Java Programmers Matrix(http://www.matrix.org.cn) T1 Log T1 Log T2 Listing 4-6 T2 (active objects) Figure 4-13: 56 247
  • 57. UML for Java Programmers Matrix(http://www.matrix.org.cn) Log logMessage Log Figure 4-14 Logger AsynchronousLogger Figure 4-15 logger Logger AsychronousLogger Logger Figure 4-16 57 247
  • 58. UML for Java Programmers Matrix(http://www.matrix.org.cn) 5 6 90 58 247
  • 59. UML for Java Programmers Matrix(http://www.matrix.org.cn) (use case) (Use case) UML UML UML (stimulus) 59 247
  • 60. UML for Java Programmers Matrix(http://www.matrix.org.cn) (stimulus) Check Out Item: 1 UPC 2 3 4 UPC 60 247
  • 61. UML for Java Programmers Matrix(http://www.matrix.org.cn) UPC Code Not ReadUPC UPC No UPC Code UPC UPC UPC Alistair Cockburn UML System Boundary Diagram Figure 5-1 (actor)(stimulus) 61 247
  • 62. UML for Java Programmers Matrix(http://www.matrix.org.cn) Java ! 62 247
  • 63. UML for Java Programmers Matrix(http://www.matrix.org.cn) OOD UML UML UML UML 12 Rigidity (Fragility) (immobility) (Viscosity) (Needless Complexity) (Needless repetition)cutpaste 63 247
  • 64. UML for Java Programmers Matrix(http://www.matrix.org.cn) (Opacity) UML (interface) (Polymorphism) OOPL [Martin2002]www.objectmmentor.com SRP GUI XML OO 64 247
  • 65. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 6-1 XML SAX JDOM Employee Access Oracle Employee Employee Employee XML Employee XML EmployeeDatabase Employee Figure 6-2 UML Figure 6-3 Persistable Employee Employee Persistable Persistable Employee Figure 6-3 Persistable Employee PersistableEmployee Employee 65 247
  • 66. UML for Java Programmers Matrix(http://www.matrix.org.cn) -OCP () Figure 6-4 EmployeeDB (facade) Employee (facade) API OCP EmployeeDB Employee Employee API Empoyee TheDatabase API (Unit test) EmployeeEmployee Employee Employee (interface) Figure 6-5 API Empolyee API Employee 66 247
  • 67. UML for Java Programmers Matrix(http://www.matrix.org.cn) Employee OCP GUI MODEL-VIEW-CONTROLLER 30 GUI GUI API TerminateTerminate Terminate Terminate(terminated) Terminate 67 247
  • 68. UML for Java Programmers Matrix(http://www.matrix.org.cn) OCP GUI API OCP GUI Figure 6-6 OCP EmployeeTerminatorModel EmployeeTerminatorDialog GUI Terminate EmployeeTerminatorModel EmployeeTerminatorDialog EmployeeTerminatorModel EmployeeTerminatorController Listing 6-1 Listing 6-4 Java EmployeeTerminatorController selectionChanged terminate terminate employee EmployeeTerminatorDialog Listing 6-1 EmployeeTerminatorView.java import java.util.Vector; public interface EmployeeTerminatorView { void enableTerminate(boolean enable); void setEmployeeList(Vector employees); void clearSelection(); } Listing 6-2 EmployeeTerminatorController.java public interface EmployeeTerminatorController { public void selectionChanged(String employee); public void terminate(); } EmployeeTerminatorModel 68 247
  • 69. UML for Java Programmers Matrix(http://www.matrix.org.cn) selectionchange Listing 6-3 EmployeeTerminatorModel.java import java.util.Vector; public class EmployeeTerminatorModel implements EmployeeTerminatorController { private EmployeeTerminatorView view; private Vector employees; private String selectedEmployee; public void initialize(Vector employees,EmployeeTerminatorView view) { this.employees = employees; this.view = view; view.setEmployeeList(employees); view.clearSelection(); view.enableTerminate(false); } // EmployeeTerminatorController interface public void selectionChanged(String employee) { view.enableTerminate(employee != null); selectedEmployee = employee; } public void terminate() { if (selectedEmployee != null) employees.remove(selectedEmployee); view.setEmployeeList(employees); view.clearSelection(); view.enableTerminate(false); } } EmployeeTerminatorDialog GUI EmployeeTerminatorView 69 247
  • 70. UML for Java Programmers Matrix(http://www.matrix.org.cn) Listing 6-4 EmployeeTerminatorDialog.java import javax.swing.*; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Vector; public class EmployeeTerminatorDialog implements EmployeeTerminatorView { private JFrame frame; private JList listBox; private JButton terminateButton; private EmployeeTerminatorController controller; private Vector employees; public static final String EMPLOYEE_LIST_NAME = quot;Employee Listquot;; public static final String TERMINATE_BUTTON_NAME = quot;Terminatequot;; public void initialize(EmployeeTerminatorController controller) { this.controller = controller; initializeEmployeeListBox(); initializeTerminateButton(); initializeContentPane(); } private void initializeEmployeeListBox() { listBox = new JList(); listBox.setName(EMPLOYEE_LIST_NAME); listBox.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) controller.selectionChanged( (String)listBox.getSelectedValue()); } } ); } private void initializeTerminateButton() { terminateButton = new JButton(TERMINATE_BUTTON_NAME); terminateButton.disable(); 70 247
  • 71. UML for Java Programmers Matrix(http://www.matrix.org.cn) terminateButton.setName(TERMINATE_BUTTON_NAME); terminateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { controller.terminate(); } } ); } private void initializeContentPane() { frame = new JFrame(quot;Employee Listquot;); frame.getContentPane().setLayout(new FlowLayout()); frame.getContentPane().add(listBox); frame.getContentPane().add(terminateButton); frame.getContentPane().setSize(300, 600); frame.pack(); } public Container getContentPane() { return frame.getContentPane(); } public JFrame getFrame() { return frame; } // functions for EmployeeTerminatorView interface public void enableTerminate(boolean enable) { terminateButton.setEnabled(enable); } public void setEmployeeList(Vector employees) { this.employees = employees; listBox.setListData(employees); frame.pack(); } public void clearSelection() { listBox.clearSelection(); } } 71 247
  • 72. UML for Java Programmers Matrix(http://www.matrix.org.cn) model dialog dialog controller model model clearSelection Figure 6-7 model dialog clearSelection dialog model setSelection modeldialog(unit test)(Listing 6-5 Listing 6-6 )OCP TestEmployeeTerminatorModel EmployeeTerminatorViewmodel model view SELF SHUNT Listing 6-5 TestEmployeeTerminatorModel.java import junit.framework.TestCase; import junit.swingui.TestRunner; import java.util.Vector; public class TestEmployeeTerminatorModel extends TestCase implements EmployeeTerminatorView { private boolean terminateEnabled = true; private String selectedEmployee; private Vector noEmployees = new Vector(); private Vector threeEmployees = new Vector(); private Vector employees = null; private EmployeeTerminatorModel m; 72 247
  • 73. UML for Java Programmers Matrix(http://www.matrix.org.cn) public static void main(String[] args) { TestRunner.main(new String[]{quot;TestEmployeeTerminatorModelquot;}); } public TestEmployeeTerminatorModel(String name) { super(name); } public void setUp() throws Exception { m = new EmployeeTerminatorModel(); threeEmployees.add(quot;Bobquot;); threeEmployees.add(quot;Billquot;); threeEmployees.add(quot;Robertquot;); } public void tearDown() throws Exception { } public void testNoEmployees() throws Exception { m.initialize(noEmployees, this); assertEquals(0, employees.size()); assertEquals(false, terminateEnabled); assertEquals(null, selectedEmployee); } public void testThreeEmployees() throws Exception { m.initialize(threeEmployees, this); assertEquals(3, employees.size()); assertEquals(false, terminateEnabled); assertEquals(null, selectedEmployee); } public void testSelection() throws Exception { m.initialize(threeEmployees, this); m.selectionChanged(quot;Bobquot;); assertEquals(true, terminateEnabled); m.selectionChanged(null); assertEquals(false, terminateEnabled); } public void testTerminate() throws Exception { m.initialize(threeEmployees, this); assertEquals(3, employees.size()); selectedEmployee = quot;Bobquot;; 73 247
  • 74. UML for Java Programmers Matrix(http://www.matrix.org.cn) m.selectionChanged(quot;Bobquot;); m.terminate(); assertEquals(2, employees.size()); assertEquals(null, selectedEmployee); assertEquals(false, terminateEnabled); assert(employees.contains(quot;Billquot;)); assert(employees.contains(quot;Robertquot;)); assert(!employees.contains(quot;Bobquot;)); } // EmployeeTerminatorView interface public void enableTerminate(boolean enable) { terminateEnabled = enable; } public void setEmployeeList(Vector employees) { this.employees = (Vector) employees.clone(); } public void clearSelection() { selectedEmployee = null; } } TestEmployeeTerminatorDialog SELF SHUNT TestTerminatorController dialog controller Listing 6-6 TestEmployeeTerminatorDialog.java import junit.framework.TestCase; import junit.swingui.TestRunner; import javax.swing.*; import java.awt.*; import java.util.HashMap; import java.util.Vector; public class TestEmployeeTerminatorDialog extends TestCase implements EmployeeTerminatorController { private EmployeeTerminatorDialog terminator; 74 247
  • 75. UML for Java Programmers Matrix(http://www.matrix.org.cn) private JList list; private JButton button; private Container contentPane; private String selectedValue = null; private int selectionCount = 0; private int terminations = 0; public static void main(String[] args) { TestRunner.main(new String[]{quot;TestEmployeeTerminatorDialogquot;}); } public TestEmployeeTerminatorDialog(String name) { super(name); } public void setUp() throws Exception { terminator = new EmployeeTerminatorDialog(); terminator.initialize(this); putComponentsIntoMemberVariables(); } private void putComponentsIntoMemberVariables() { contentPane = terminator.getContentPane(); HashMap map = new HashMap(); for (int i = 0; i < contentPane.getComponentCount(); i++) { Component c = contentPane.getComponent(i); map.put(c.getName(), c); } list = (JList) map.get( EmployeeTerminatorDialog.EMPLOYEE_LIST_NAME); button = (JButton) map.get( EmployeeTerminatorDialog.TERMINATE_BUTTON_NAME); } private void putThreeEmployeesIntoTerminator() { Vector v = new Vector(); v.add(quot;Bobquot;); v.add(quot;Billquot;); v.add(quot;Borisquot;); terminator.setEmployeeList(v); } public void testCreate() throws Exception { assertNotNull(contentPane); 75 247
  • 76. UML for Java Programmers Matrix(http://www.matrix.org.cn) assertEquals(2, contentPane.getComponentCount()); assertNotNull(list); assertNotNull(button); assertEquals(false, button.isEnabled()); } public void testAddOneName() throws Exception { Vector v = new Vector(); v.add(quot;Bobquot;); terminator.setEmployeeList(v); ListModel m = list.getModel(); assertEquals(1, m.getSize()); assertEquals(quot;Bobquot;, m.getElementAt(0)); } public void testAddManyNames() throws Exception { putThreeEmployeesIntoTerminator(); ListModel m = list.getModel(); assertEquals(3, m.getSize()); assertEquals(quot;Bobquot;, m.getElementAt(0)); assertEquals(quot;Billquot;, m.getElementAt(1)); assertEquals(quot;Borisquot;, m.getElementAt(2)); } public void testEnableTerminate() throws Exception { terminator.enableTerminate(true); assertEquals(true, button.isEnabled()); terminator.enableTerminate(false); assertEquals(false, button.isEnabled()); } public void testClearSelection() throws Exception { putThreeEmployeesIntoTerminator(); list.setSelectedIndex(1); assertNotNull(list.getSelectedValue()); terminator.clearSelection(); assertEquals(null, list.getSelectedValue()); } public void testSelectionChangedCallback() throws Exception { putThreeEmployeesIntoTerminator(); list.setSelectedIndex(1); assertEquals(quot;Billquot;, selectedValue); assertEquals(1, selectionCount); 76 247
  • 77. UML for Java Programmers Matrix(http://www.matrix.org.cn) list.setSelectedIndex(2); assertEquals(quot;Borisquot;, selectedValue); assertEquals(2, selectionCount); } public void testTerminateButtonCallback() throws Exception { button.doClick(); assertEquals(1, terminations); } // implement EmployeeTerminatorController public void selectionChanged(String employee) { selectedValue = employee; selectionCount++; } public void terminate() { terminations++; } } OCP dialog model dialog model UI() UI dialog model model dialog RMI OCP Figure 6-6 FLIP-FLOP OCP OCP OCP test-first Listing 6-7 model model dialog 77 247
  • 78. UML for Java Programmers Matrix(http://www.matrix.org.cn) Listing 6-7 ShowEmployeeTerminator.java import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Vector; public class ShowEmployeeTerminator { static Vector employees = new Vector(); static EmployeeTerminatorDialog dialog; public static void main(String[] args) { initializeEmployeeVector(); initializeDialog(); runDialog(); } private static void initializeEmployeeVector() { employees.add(quot;Bobquot;); employees.add(quot;Billquot;); employees.add(quot;Robertquot;); } private static void initializeDialog() { EmployeeTerminatorModel model = new EmployeeTerminatorModel(); dialog = new EmployeeTerminatorDialog(); dialog.initialize(model); model.initialize(employees, dialog); } private static void runDialog() { dialog.getFrame().addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { for (int i = 0; i < employees.size(); i++) { String s = (String) employees.elementAt(i); System.out.println(s); } System.exit(0); } } ); dialog.getFrame().setVisible(true); 78 247
  • 79. UML for Java Programmers Matrix(http://www.matrix.org.cn) } } Liskov (LSP) (subtypes)(base types) if instanceof LSP OCP LSP (base classs) instanceof (Downcast) Figure 6-8 Employee calcPay SalariedEmployee HourlyEmployee VolunteerEmployee calcPay 0 calcPay VolunteerEmployee calcPay calcPay 0 79 247
  • 80. UML for Java Programmers Matrix(http://www.matrix.org.cn) 0 VolunteerEmployee calcPay calcPay UnpayableEmloyeeException try/catch Employee LSP VolunteerEmployee Employee if instanceof OCP LSP LSP 80 247
  • 81. UML for Java Programmers Matrix(http://www.matrix.org.cn) instanceof LSP VolunteerEmployee Volunteers calcPay Employee calcPay (DIP) A B () Vector String DIP Vector String UML UML DIP ISP (fat class) 81 247
  • 82. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 6-9 StudentEnrollment EnrollmentReportGenerator prepareInvoice postPayment AccountsReceivable getName getDate postPayment StudentEnrollment EnrollmentReportGenerator EnrollmentReportGenerator postPayment 82 247
  • 83. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 6-10 StudentEnrollment 1 SRP 2 OCP 3 LSP 4 DIP 5 ISP OCP SRP ISP DIP (proactively)(reactively) (the sore spots) [Feathers2001]: The 'Self'-Shunt Unit Testing Pattern, Michael Feathers, May, 2001, 83 247
  • 84. UML for Java Programmers Matrix(http://www.matrix.org.cn) http://www.objectmentor.com/resources/articles/SelfShunPtrn.pdf [Martin2002]: The Principles, Patterns, and Practices of Agile Software Development, Robert C. Martin, Prentice Hall, 2002 2 84 247
  • 85. UML for Java Programmers Matrix(http://www.matrix.org.cn) dX Melthaw Zhang dX dX dX s use-case use-case user story story use-case use case N 85 247
  • 86. UML for Java Programmers Matrix(http://www.matrix.org.cn) story story 8 story 4 story story story 6 story story 5 6 7 story story story story story story 3 4 story story story story 7 story 5 5 7 3 15 7 86 247
  • 87. UML for Java Programmers Matrix(http://www.matrix.org.cn) story story 5 50 300 0.5 150 story 150 story story story 50 25 story 25 story story story 4 10 story 87 247
  • 88. UML for Java Programmers Matrix(http://www.matrix.org.cn) 25 story . 20 story story 10 story story story story story 10 story 8 story 16 story story story 16 story 15 story 30 story story. story 23 story 23 story story 23 story story 88 247
  • 89. UML for Java Programmers Matrix(http://www.matrix.org.cn) . story story story . story dX 89 247
  • 90. UML for Java Programmers Matrix(http://www.matrix.org.cn) . . dX story QA user story use-case story dX 510 6 110 90 247
  • 91. UML for Java Programmers Matrix(http://www.matrix.org.cn) . API . , dX dX dX check out check out check in check 91 247
  • 92. UML for Java Programmers Matrix(http://www.matrix.org.cn) in check out check in dX check in check in check in dX UML JAVA dX UML JAVA UML dX Martin UML sequence use-case . dX UML UML dX UML dX XP() XP dX [Kruchten1998]: The Rational Unified Process, Philippe Kruchten, Addison Wesley, 92 247
  • 93. UML for Java Programmers Matrix(http://www.matrix.org.cn) Reading, MA, 1998. [Fowler1999]: Refactoring, Martin Fowler, Addison Wesley, Reading, MA, 1999 [Martin1999]: RUP vs. XP, Robert C. Martin, 1999, http://www.objectmentor.com/resources/articles/RUPvsXP.pdf [Beck1999]: Extreme Programming Explained, Kent Beck, Addison Wesley, Reading, MA, 1999 [Jeffries2000]: Extreme Programming Installed, Ron Jeffries, et. al, Addison Wesley, Upper Saddle River, NJ, 2000 6. [Beck1999], [Jeffries2000] 93 247
  • 94. UML for Java Programmers Matrix(http://www.matrix.org.cn) (Packages) Orient Sun Java Java package .jar Java Java Packages Java packages (namespaces) Java .class A.B.C .class A/B/C.class Java .class .java classpath UML Packages UML Figure 8-1 Figure 8-2 94 247
  • 95. UML for Java Programmers Matrix(http://www.matrix.org.cn) contains Figure 8-3 Dependencies Java import UML dependency Figure 8-4 import consultantScheduler.ConsultantCalendar calendarUtilities.Calendar Java import .jar Binary Components .jar 95 247
  • 96. UML for Java Programmers Matrix(http://www.matrix.org.cn) UML Figure 8-5 CalendarRenderer Calendar Principles of Package Design [PPP2002]1 /The Release/Reuse Equivalency Principle (REP) 96 247
  • 97. UML for Java Programmers Matrix(http://www.matrix.org.cn) The Common Closure Principle (CCP) SRPCCP CCP The Common Reuse Principle (CRP) ISP CRP The Acyclic Dependencies Principle (ADP) A B B C A C JDepend (see www.clarkware.com) The Stable Dependencies Principle (SDP) , 97 247
  • 98. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 8-6 () [PPP2002] The Stable Abstractions Principle (SAP) OCP SAP SAP SDP SAP DIP DIP SDP SAP [PPP2002] 98 247
  • 99. UML for Java Programmers Matrix(http://www.matrix.org.cn) ADP build problems 2 2. see www.clarkware.com for just such a tool. 99 247
  • 100. UML for Java Programmers Matrix(http://www.matrix.org.cn) Object Diagrams Orient Sun UML (Snapshot) (GUI) Figure 9-1 Figure 9-2 Figure 9-2 Space Space 100 247
  • 101. UML for Java Programmers Matrix(http://www.matrix.org.cn) Active Objects Listing 9-1 SocketService socket socket 101 247
  • 102. UML for Java Programmers Matrix(http://www.matrix.org.cn) 102 247
  • 103. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 9-3 Figure 9-4 SocketService serviceThread serviceThread serviceThread ServerRunner (Active Ojbect) startstop setPriority Thread Runnable Runnable Runnable 103 247
  • 104. UML for Java Programmers Matrix(http://www.matrix.org.cn) 104 247
  • 105. UML for Java Programmers Matrix(http://www.matrix.org.cn) (State Diagrams) LiShiFeng UML FSM FSM (GUI) FSM FSM Figure 10-1 State Transition Diagram (STD) 105 247
  • 106. UML for Java Programmers Matrix(http://www.matrix.org.cn) Prompting for LoginshowLoginScreen Prompting for LoginhideLoginScreen (Transition) Prompting for Loginlogin Validating UservalidateUser Figure 10-1 initial pseudo state Prompting for Login superstate Sending Password Failed Sending Password Succeeded OK Prompting for Login showLoginScreen validateUser dsendPassword Login event / action Figure 10-2 entry exit Figure 10-2 FSM 106 247
  • 107. UML for Java Programmers Matrix(http://www.matrix.org.cn) UMLFigure 10-3 UMLTransition exitTransitionentry UMLFigure 10-3myAction exitentry Figure 10-1 loginFSM Figure 10-4 TransitionTransition Figure 10-5 S3 pause Cancelable 107 247
  • 108. UML for Java Programmers Matrix(http://www.matrix.org.cn) pause, entryexit Figure 10-6 FSM exit entry FSM Some State SubenterSuperenterSub FSM Sub2 Some State exitSub2exitSuper SubSub2e2 exitSub enterSub2 108 247
  • 109. UML for Java Programmers Matrix(http://www.matrix.org.cn) Figure 10-7 UML FMS FSM FSM FSM FSMs STTsState Transition Figure 10-8 Tables STDsState Transition Diagrams STT Figure 10-9 109 247
  • 110. UML for Java Programmers Matrix(http://www.matrix.org.cn) STT STT Locked coin Unlocked Unlock Locked coin Unlocked Unlock Locked pass Locked Alarm Unlocked coin Unlocked Refund Unlocked pass Locked Lock 16 SMC 15 SMCSTT C++STTSMC SMCwww.objectmentor.com SMC Listing 10-1 smc.txt URL 110 247
  • 111. UML for Java Programmers Matrix(http://www.matrix.org.cn) FSMName SMC Context SMC FSM Listing 10-2 Context Listing 10-1 Turnstile.sm Context TurnStileContext FSMName TurnStile Initial Locked { Locked { Coin Unlocked Unlock Pass Locked Alarm } Unlocked { Coin Unlocked Thankyou Pass Locked Lock } } Listing 10-2 TurnStile.java (Generated) public class TurnStile extends TurnStileContext { private State itsState; private static String itsVersion = quot;quot;; private static Locked itsLockedState; private static Unlocked itsUnlockedState; public TurnStile() { itsLockedState = new Locked(); itsUnlockedState = new Unlocked(); itsState = itsLockedState; } public String getVersion() { return itsVersion; } 111 247
  • 112. UML for Java Programmers Matrix(http://www.matrix.org.cn) public String getCurrentStateName() { return itsState.stateName(); } public void Pass() { itsState.pass(); } public void Coin() { itsState.coin(); } private abstract class State { public abstract String stateName(); public void pass() { FSMError(quot;Passquot;, itsState.stateName()); } public void coin() { FSMError(quot;Coinquot;, itsState.stateName()); } } private class Locked extends State { public String stateName() { return quot;Lockedquot;; } public void pass() { Alarm(); itsState = itsLockedState; } public void coin() { Unlock(); itsState = itsUnlockedState; } } private class Unlocked extends State { public String stateName() { return quot;Unlockedquot;; } public void pass() { Lock(); itsState = itsLockedState; } 112 247
  • 113. UML for Java Programmers Matrix(http://www.matrix.org.cn) public void coin() { Thankyou(); itsState = itsUnlockedState; } } } FSM ICE ICE GUI Figure 10-10 UML FSM 113 247
  • 114. UML for Java Programmers Matrix(http://www.matrix.org.cn) SMC Listing 10-3 Listing 10-3 ice.sm Context RootFSM 114 247
  • 115. UML for Java Programmers Matrix(http://www.matrix.org.cn) Initial init FSMName RootFSMGen Version 042399 1528 rcm FSMGenerator smc.generator.java.SMJavaGenerator Pragma Package root { init { init login {} } login hideLoginScreen { login determiningUserMode {} cancel end {} } determiningUserMode < { cleanupThumbnails checkUserState } { auto autoBatch {} manual gettingManualBatch { createSelector } } autoBatch < { setUserAuto displayThumbnailAuto } { manual gettingManualBatch { createSelector } select gettingAutoBatch { createSelector } itemChanged * workTypeItemChanged redisplay * displayThumbnailAuto exit end {} } gettingAutoBatch
  • 116. UML for Java Programmers Matrix(http://www.matrix.org.cn) manualBatch < { setUserManual displayThumbnailManual } { auto autoBatch {} refresh gettingManualBatch {} select batchSplashManual selectManualBatch redisplay * displayThumbnailManual exit end {} } (processingBatch) >hideThumbnailScreen { ok * {} cancel * {} complete determiningUserMode { completeBatch cleanupBatch } requeue determiningUserMode { requeueBatch cleanupBatch } reject determiningUserMode { rejectBatch cleanupBatch } assign * assignPage exit end requeueBatch } processingAutoBatch : processingBatch { stop processingAutoBatchStopped {} complete gettingAutoBatch { completeBatch cleanupBatch } reject gettingAutoBatch { rejectBatch cleanupBatch } openPage pageAutoBatch {} redisplay * displayAutoThumbnailProcessing } processingAutoBatchStopped : processingBatch { complete determiningUserMode { completeBatch cleanupBatch } reject determiningUserMode { rejectBatch cleanupBatch } openPage pageAutoBatchStopped {} stop processingAutoBatch {} redisplay * 116 247
  • 117. UML for Java Programmers Matrix(http://www.matrix.org.cn) displayAutoThumbnailProcessing } processingManualBatch : processingBatch { openPage pageManualBatch {} redisplay * displayManualThumbnailProcessing } (batchSplash) hideBatchSplashScreen { } batchSplashAuto : batchSplash { ok processingAutoBatch {allMode initBatch displayAutoThumbnailProcessing} complete gettingAutoBatch {completeBatch hideThumbnailScreen} } batchSplashManual : batchSplash { ok processingManualBatch {allMode initBatch displayManualThumbnailProcessing} complete determiningUserMode {completeBatch hideThumbnailScreen} } (page) hidePageScreen { assign * {assignPage redisplayPageScreen} setZone * {assignZone redisplayPageScreen} } pageAutoBatch : page { goBack processingAutoBatch displayAutoThumbnailProcessing } pageAutoBatchStopped : page { goBack processingAutoBatchStopped displayAutoThumbnailProcessing 117 247
  • 118. UML for Java Programmers Matrix(http://www.matrix.org.cn) } pageManualBatch : page { goBack processingManualBatch displayManualThumbnailProcessing } end
  • 119. UML for Java Programmers Matrix(http://www.matrix.org.cn) Melthaw Zhang OO UML Mark IV OOD UML OOD Mark IV Mark IV 12 12 warmerEmpty, potEmpty ,potNotEmpty 119 247
  • 120. UML for Java Programmers Matrix(http://www.matrix.org.cn) boilerEmpty boilerNotEmpty Mark IV IO 111 Listing 11-1 CofeeMakerAPI.java public interface CoffeeMakerAPI { public static CoffeeMakerAPI api = null; // set by main. /** * This function returns the status of the warmer-plate * sensor. This sensor detects the presence of the pot * and whether it has coffee in it. */ public int getWarmerPlateStatus(); public static final int WARMER_EMPTY = 0; public static final int POT_EMPTY = 1; public static final int POT_NOT_EMPTY = 2; /** * This function returns the status of the boiler switch. * The boiler switch is a float switch that detects if * there is more than 1/2 cup of water in the boiler. */ public int getBoilerStatus(); public static final int BOILER_EMPTY = 0; public static final int BOILER_NOT_EMPTY = 1; /** * This function returns the status of the brew button. 120 247
  • 121. UML for Java Programmers Matrix(http://www.matrix.org.cn) * The brew button is a momentary switch that remembers * its state. Each call to this function returns the * remembered state and then resets that state to * BREW_BUTTON_NOT_PUSHED. * *Thus, even if this function is polled at a very slow * rate, it will still detect when the brew button is * pushed. */ public int getBrewButtonStatus(); public static final int BREW_BUTTON_PUSHED = 0; public static final int BREW_BUTTON_NOT_PUSHED = 1; /** * This function turns the heating element in the boiler * on or off. */ public void setBoilerState(int boilerStatus); public static final int BOILER_ON = 0; public static final int BOILER_OFF = 1; /** * This function turns the heating element in the warmer * plate on or off. */ public void setWarmerState(int warmerState); public static final int WARMER_ON = 0; public static final int WARMER_OFF = 1; /** * This function turns the indicator light on or off. * The indicator light should be turned on at the end * of the brewing cycle. It should be turned off when * the user presses the brew button. */ public void setIndicatorState(int indicatorState); public static final int INDICATOR_ON = 0; public static final int INDICATOR_OFF = 1; /** 121 247
  • 122. UML for Java Programmers Matrix(http://www.matrix.org.cn) * This function opens and closes the pressure-relief * valve. When this valve is closed, steam pressure in * the boiler will force hot water to spray out over * the coffee filter. When the valve is open, the steam * in the boiler escapes into the environment, and the * water in the boiler will not spray out over the filter. */ public void setReliefValveState(int reliefValveState); public static final int VALVE_OPEN = 0; public static final int VALVE_CLOSED = 1; } 122 247
  • 123. UML for Java Programmers Matrix(http://www.matrix.org.cn) 11-1 CoffeeMaker CoffeeMaker Boiler WarmerPlate Button Light Boiler BoilerSensor BoilerHeater WarmerPlate PlateSensor PlateHeaterSenor Heater Boiler WarmerPlate UML 11-1 UML 123 247
  • 124. UML for Java Programmers Matrix(http://www.matrix.org.cn) Light Light on() off() Light 11-2 Light on() off() CoffeeMakerAPI setIndicatorStateLight ButtonBoiler WarmerPlate adapter CoffeeMaker CofferMakerAPI Adapter. 11-1