Presentation is loading. Please wait.

Presentation is loading. Please wait.

UML a crash course Alex Lo Brian Kiefer. Overview Classes Class Relationships Interfaces Objects States Worksheet.

Similar presentations


Presentation on theme: "UML a crash course Alex Lo Brian Kiefer. Overview Classes Class Relationships Interfaces Objects States Worksheet."— Presentation transcript:

1 UML a crash course Alex Lo Brian Kiefer

2 Overview Classes Class Relationships Interfaces Objects States Worksheet

3 Classes Drawn as a three section box: Name Fields Functions

4 Classes Fields and functions given visibility signs + sign indicates public - sign indicates private # sign indicates protected Fields are shown as name:type Functions are shown as Function(argument1:type, …):returnType Italic class or method names indicate the class is abstract Static fields and functions are underlined

5 Cooper Example public abstract class Person { protected String personName; private int age; public Person (String name) { personName = name; } static public String makeJob () {return "hired";} public int getAge () {return age;} private void splitNames () { } abstract String getJob (); }

6 Alternate Diagrams

7 Packages Packages are depicted as large folders with classes contained inside Package Name

8 Notes UML does not require that you show everything To draw a note in UML

9 Class Relationships Use a solid line with a hollow arrowhead to show a parent class Class2 extends Class1

10 Cooper Example public class Employee extends Person { public Employee (String name) { super (name); } public String getJob () { return "Research Staff"; } }

11 Relationships A single line often represents that one class contains an instance of another Use a diamond to show that one class has a collection of the other class Sometimes a small circle is used to show that the instance is singular

12 Relationship Cardinality Exactly 1 Many (0 and up) Optional (0 or 1) One or more N to M (not shown)

13 Relationships An open arrow indicates navigability – it shows that one class has a ref to another and the other may not

14 Dependency A dashed arrow shows a dependency on a class that does not use an object ref Example: using static method of another class others?

15 Other Relations Another relation can be done using the dashed arrows like throwing (bind can be any keyword, such as throw, send, become, friend, etc)

16 Interfaces Interfaces are drawn similarly to classes, except without a field area (usually) and the > stereotype An interface which you don’t need to define can be drawn as a “lollipop”

17 Interfaces To show a class implements an interface, use a dashed line with an open arrowhead

18 Notes on Interfaces While interfaces and their methods are always abstract in java, their methods do not appear italicized. As opposed to abstract classes and abstract methods. *This was disagreed on between Cooper and our book.

19 Objects You can show an object by giving its name and type separated by a colon (or just either/or) and underlining it A line between objects indicates that one object has a reference to another.

20 Calling Methods from Objects You can show a sequence of objects calling methods of other objects The order is from top to bottom The dashed line indicates the object over time A bold outline of the box represents the class is running on a separate thread

21 States UML can also be used to model the various states of a program or method Think Introduction to Logic Design Think events (clicks, key presses, etc.)

22 Other uses of UML Collaboration diagrams Use case diagrams Activity diagrams Deployment diagrams Etc.

23 More Resources Our book, p 442-447 Safari Online: Java™ Design Patterns: A Tutorial By James W. Cooper Chapter 2 UML Distilled

24

25 Discussion


Download ppt "UML a crash course Alex Lo Brian Kiefer. Overview Classes Class Relationships Interfaces Objects States Worksheet."

Similar presentations


Ads by Google