Presentation is loading. Please wait.

Presentation is loading. Please wait.

UML for Java Programmers Object Mentor, Inc. Copyright  1998-2001 by Object Mentor, Inc All Rights Reserved www.objectmentor.com www.junit.orgwww.xprogramming.comfitnesse.org.

Similar presentations


Presentation on theme: "UML for Java Programmers Object Mentor, Inc. Copyright  1998-2001 by Object Mentor, Inc All Rights Reserved www.objectmentor.com www.junit.orgwww.xprogramming.comfitnesse.org."— Presentation transcript:

1

2 UML for Java Programmers Object Mentor, Inc. Copyright  1998-2001 by Object Mentor, Inc All Rights Reserved www.objectmentor.com www.junit.orgwww.xprogramming.comfitnesse.org Or How Uncle Bob uses UML.

3 2 The three modes of UML Conceptual Tied to human language. Specification A description of source code yet to be written. Implementation A description of source code that already exists.

4 3 Conceptual Tied to human language: “An Animal ISA Dog”

5 4 Hmmm…

6 5 Tied to human language

7 6 Models of the “Real World” Do not relate to software structure. Now it’s time for: Uncle Bob’s rant…. Human language is not the best foundation for software structure. A Circle ISA Ellipse.

8 7 A Circle ISA Ellipse

9 8 Specification and Implementation Are tied to code. Follow the same rules. Differ only in detail. Sometimes.

10 9 Example: public class TreeMap { TreeMapNode topNode = null; public void add(Comparable key, Object value) {…} public Object get(Comparable key) {…} } class TreeMapNode { private Comparable itsKey; private Object itsValue; private TreeMapNode nodes[] = new TreeMapNode[2]; public TreeMapNode(Comparable key, Object value) {…} public Object find(Comparable key) {…} public void add(Comparable key, Object value) {…} }

11 10 Here’s some UML for that.

12 11 Classes and Relationships. Rectangles represent classes, and arrows represent relationships.

13 12 Associations. In this diagram all the relationships are associations. Associations are simple data relationships in which one object holds a reference to, and invokes methods upon, the other.

14 13 Relationship Names. The name on an association maps to the name of the variable that holds the reference. public class TreeMap { TreeMapNode topNode = null; }

15 14 Multiplicity. A number next to an arrowhead typically shows the number of instances held by the relationship. If that number is greater than one then some kind of container, like an array, is implied. class TreeMapNode { private TreeMapNode nodes[] = new TreeMapNode[2]; }

16 15 Class Icons. Class icons can have more than one compartment. The top compartment always holds the name of the class. The other compartments describe functions and variables.

17 16 Interface. The «interface» notation means that Comparable is an interface.

18 17 Optional. Most of the notations shown are optional Uncle Bob is going to rant again…

19 18 >. But Uncle Bob, you didn’t talk about Aggregation or Composition. Rant….

20 19 Object Diagrams.

21 20 Freeze Frame. It shows a set of objects and relationships at a particular moment in the execution of the system. You can view it as a snapshot of memory.

22 21 Object Names are Underlined. the rectangle icons represent objects. You can tell that they are objects because their names are underlined.

23 22 Object : Class The name after the colon is the name of the class that the object belongs to.

24 23 Values. Note that the lower compartment of each object shows the value of that object’s itsKey variable.

25 24 Links. The relationships between the objects are called links, and are derived from the associations.

26 25 Sequence Diagrams. public void add(Comparable key,Object value){ if (topNode == null) topNode = new TreeMapNode(key, value); else topNode.add(key, value); }

27 26 Actor. The stick figure (actor) represents an unknown caller.

28 27 Lifelines. The dashed lines are lifelines, they show the lifetime of the objects they descend from.

29 28 Messages. The long arrows are messages sent between the objects.

30 29 Guards. The boolean expressions inside square brackets are called guards. They show which path is taken.

31 30 Construction. The message arrow that terminates on the TreeMapNode icon represents construction.

32 31 Data Tokens The little arrows with circles are called data tokens. They show any arguments or return values.

33 32 Activations. The skinny rectangle below TreeMap is called an activation. It depicts how much time the add method executes.

34 33 Collaboration Diagrams.

35 34 Same data as Sequence Diagrams. Collaboration diagrams make the relationships between the objects clear.

36 35 Links (again). The objects are connected by relationships called links. A link exists wherever one object can send a message to another.

37 36 Messages. Traveling over those links are the messages themselves. They are depicted as the smaller arrows.

38 37 Message Labels. The messages are labeled with the name of the message, its sequence number, and any guards that apply.

39 38 Sequence Numbers. The dot structure of the sequence number shows the calling hierarchy.

40 39 State Diagrams. A Subway Turnstile.

41 40 States. There are two states named Locked and Unlocked.

42 41 Events. Two events may be sent to the machine. The coin event means that the user has dropped a coin into the turnstile. The pass event means that the user has passed through the turnstile.

43 42 Transitions. The arrows are called transitions. They are labeled with the event that triggers the transition and the action that the transition performs.

44 43 Interpretation. If we are in the Locked state and we get a coin event, then we transition to the Unlocked state and we invoke the Unlock function. If we are in the Unlocked state and we get a pass event, then we transition to the Locked state and we invoke the Lock function. If we are in the Unlocked state and we get a coin event, then we stay in the Unlocked state and we call the Thankyou function. If we are in the Locked state and we get a pass event, then we stay in the Locked state and we call the Alarm function.

45 44 Sufficiency. The diagrams shown in this chapter are enough for most purposes. Most programmers could live without any more knowledge of UML that what is shown here.

46 45 Tools. Now ask me what I think about tools…..

47 46 Documentation.

48 47 Where to get this presentation.


Download ppt "UML for Java Programmers Object Mentor, Inc. Copyright  1998-2001 by Object Mentor, Inc All Rights Reserved www.objectmentor.com www.junit.orgwww.xprogramming.comfitnesse.org."

Similar presentations


Ads by Google