UML class diagrams What are they Unified Modeling

  • Slides: 5
Download presentation
UML class diagrams: What are they? • Unified Modeling Language (UML) – “A family

UML class diagrams: What are they? • Unified Modeling Language (UML) – “A family of graphical notations … that help in describing and designing [object-oriented] software systems” – Martin Fowler – Developed in 1997 to unify the previous object-oriented graphical modeling languages – Now the world-wide standard • We focus on UML class diagrams – These show: • Relationships between classes in the software system • Details of the classes Fundamentals of Software Development 1 1

A relationshipsonly UML class diagram 1 * 1. . * 0. . 1 •

A relationshipsonly UML class diagram 1 * 1. . * 0. . 1 • is-a (by extending a class) • is-a (by implementing an interface) • has-a means one means 0 or more means 1 or more means 0 or 1 Person * * Man Daughter Son This diagram might also show which objects are to construct which other objects Fundamentals of Software Development 1 Woman 1 Father 1 Mother Person. Able. To. Procreate <<interface>> 2

A relationships-only UML class diagram Instructor: give each student a paper copy of this

A relationships-only UML class diagram Instructor: give each student a paper copy of this slide. The example is taken from Martin Fowler’s UML Distilled, 3 rd Edition. Exercise: draw arrows to indicate the relationships between these classes in an order-processing system. For example, think of the company as Amazon and the system as Amazon’s system for processing orders from customers. After drawing the arrows, indicate the multiplicities. Order Customer line. Item Order Line Product is-a (by extending a class) is-a (by implementing an interface) Fundamentals of Software has-a Development 1 Corporate Customer sales. Rep Employee Personal Customer 1 * 1. . * 0. . 1 means one means 0 or more means 1 or more means 0 or 1 3

One answer to the exercise on the previous slide Exercise: draw arrows to indicate

One answer to the exercise on the previous slide Exercise: draw arrows to indicate the relationships between these classes in an orderprocessing system. For example, think of the company as Amazon and the system as Amazon’s system for processing orders from customers. Here is one answer, but not the only possible one! Depends on exactly what you want to model… Order 1 line. Item 1 * * Order Line * Corporate Customer 1 Product is-a (by extending a class) is-a (by implementing an interface) Fundamentals of Software has-a Development 1 Customer * 0. . 1 sales. Rep Employee Personal Customer 1 * 1. . * 0. . 1 means one means 0 or more means 1 or more means 0 or 1 4

UML class diagrams • What they are – A notation to assist object-oriented design

UML class diagrams • What they are – A notation to assist object-oriented design (not just Java) • Why use UML? – UML as sketch This is how we (and most people) use UML class diagrams – as a tool to help our thinking • To figure out a design • To communicate ideas and alternatives – UML as blueprint • To convey the design to the coder – UML as programming language • To generate code automatically from the design Fundamentals of Software Development 1 5