UML and its UseCase Modeling Professor Chen School

  • Slides: 52
Download presentation
UML and its Use-Case Modeling Professor Chen School of Business Gonzaga University Spokane, WA

UML and its Use-Case Modeling Professor Chen School of Business Gonzaga University Spokane, WA 99258 chen@gonzaga. edu

Methods vs. Modeling Languages n n A model has its purpose of structuring our

Methods vs. Modeling Languages n n A model has its purpose of structuring our thoughts A method – is an explicit way of structuring one’s thinking and actions – tells us: • • What to do How to do it When to do it Why it’s done UML (Use-Case Modeling), Dr. Chen TM -2

Method, Modeling Language and Process Modeling Language METHOD = + PROCESS UML (Use-Case Modeling),

Method, Modeling Language and Process Modeling Language METHOD = + PROCESS UML (Use-Case Modeling), Dr. Chen TM -3

Process vs. Method n n A process is a group of activities that, if

Process vs. Method n n A process is a group of activities that, if done correctly, will achieve an explicit goal. A method, in contrast, is normally also considered as a set of related activities, but without explicit goals, resources, and rules. UML (Use-Case Modeling), Dr. Chen TM -4

What is a Process? Rules << Ut ili ze >> [VALUE] Resources Process Documentation,

What is a Process? Rules << Ut ili ze >> [VALUE] Resources Process Documentation, Products, Models Humans, computers tools, Information UML (Use-Case Modeling), Dr. Chen What to do, How to do it, When to do it, Why it should be done etc. TM -5

What is a Process? Rules << > e> iliz Ut Resources Humans, computers tools,

What is a Process? Rules << > e> iliz Ut Resources Humans, computers tools, Information UML (Use-Case Modeling), Dr. Chen Software Development: [VALUE] Process CONTEXT, USER, STEPS Process A process is a group of activities that, if done correctly, will achieve an explicit goal. Documentation, Products, Models etc. What to do, How to do it, When to do it, Why it should be done TM -6

What is the UML? n n The Unified Modeling Language (UML) is a graphical

What is the UML? n n The Unified Modeling Language (UML) is a graphical language for visualizing, specifying, constructing, and documenting the artifacts of a software-intensive systems. UML is only a modeling language without a process – it is a lot easier to comprehend than a natural language UML (Use-Case Modeling), Dr. Chen TM -7

What does UML give you? n The UML gives you a standard way to

What does UML give you? n The UML gives you a standard way to write a system’s blueprints covering conceptual things, such as business processes and system functions, as well as concrete thins, such as classes written in a specific programming language, database schemas, and reusable software components. UML (Use-Case Modeling), Dr. Chen TM -8

How Applicable of UML? n The UML is applicable to anyone involved in the

How Applicable of UML? n The UML is applicable to anyone involved in the production, deployment, and maintenance of software. UML (Use-Case Modeling), Dr. Chen TM -9

What is Visual Modeling? n n VISUAL MODELING is a way of thinking about

What is Visual Modeling? n n VISUAL MODELING is a way of thinking about problems using (graphical) models organized around real-world idea. UML is a product of VISUAL MODELING language. UML (Use-Case Modeling), Dr. Chen TM -10

Models are useful for. . n n n understanding problems, communicating with everyone involved

Models are useful for. . n n n understanding problems, communicating with everyone involved with project (customer, domain experts, analysts, designers, etc. ) modeling enterprise, preparing documentation, and designing programs and databases UML (Use-Case Modeling), Dr. Chen TM -11

Objectives of the Modeling promotes: n better understanding of requirements, n cleaner designs, and

Objectives of the Modeling promotes: n better understanding of requirements, n cleaner designs, and n more maintainable systems. UML (Use-Case Modeling), Dr. Chen TM -12

What is a Good Model? A model is good when: Ê it is a

What is a Good Model? A model is good when: Ê it is a relevant model Ë it is possible to communicate Ì it fits purpose Í it captures the essentials UML (Use-Case Modeling), Dr. Chen TM -13

Figure: A Use-Cases Example System Boundary ACTOR Use Case > e t ia t

Figure: A Use-Cases Example System Boundary ACTOR Use Case > e t ia t i n i < > n u m om <c <send> <receive> te a c i Signing an insurance policy Sales Statistics l b i g v eli (Role) UML (Use-Case Modeling), Dr. Chen alu v e o> t e an t r e <d Customer Statistics TM -14

Purposes of the Use-Case Modeling n n What a new system should do What

Purposes of the Use-Case Modeling n n What a new system should do What an existing system already does UML (Use-Case Modeling), Dr. Chen TM -15

What is an Actor? n n n An actor is a class not an

What is an Actor? n n n An actor is a class not an instance. It represents a role, not an individual user of the system. primary vs. secondary actors – customer/user, developer, test teams vs. manager or board members n active vs. passive UML (Use-Case Modeling), Dr. Chen TM -16

Figure: An Library Use-Cases Example Library Borrow books Return books Interlibrary loan Circulation Clerk

Figure: An Library Use-Cases Example Library Borrow books Return books Interlibrary loan Circulation Clerk Do research Member Read books, newspaper Purchase supplies Supplier UML (Use-Case Modeling), Dr. Chen TM -17

Summary n n Use-case modeling is a technique used to describe the functional requirements

Summary n n Use-case modeling is a technique used to describe the functional requirements of a system A use case is a set of sequence of actions performed in the system. A scenario is an illustration or an example (instance) of a use case or collaboration. An actor represents a role that an external entity (user, hardware) plays in interacting with the system. UML (Use-Case Modeling), Dr. Chen TM -18

Insurance company 1 0. . * Insurance contract 0. . * Figure 4. 1:

Insurance company 1 0. . * Insurance contract 0. . * Figure 4. 1: A simple mode of an insurance business. One insurance company has many (zero-to-many) insurance contracts. An insurance customer has many (zero-to-many) insurance contracts. An insurance contract is related to one insurance company. The insurance contract is related to many (one-to-many) insurance customers. The entities shown in the model are classes. UML (Use-Case Modeling), Dr. Chen 1. . * Customer TM -19

Name Attributes Operations Figure 4. 2 A Class in UML (Use-Case Modeling), Dr. Chen

Name Attributes Operations Figure 4. 2 A Class in UML (Use-Case Modeling), Dr. Chen TM -20

Car registration number data speed direction Figure 4. 3 A class car with the

Car registration number data speed direction Figure 4. 3 A class car with the attributes registration number, data, speed, and direction. Attribute names typically begin with a lowercase letter UML (Use-Case Modeling), Dr. Chen TM -21

Car Invoice registration number: String data: Car. Data speed: integer direction: Direction +amount :

Car Invoice registration number: String data: Car. Data speed: integer direction: Direction +amount : Real + date: Date + customer: String +specification: String -administrator: String Figure 4. 4 The car with typed attributes UML (Use-Case Modeling), Dr. Chen Figure 4. 5: A class with public and private attributes TM -22

Invoice +amount : Real + date: Date=Current date + customer: String +specification: String -administrator:

Invoice +amount : Real + date: Date=Current date + customer: String +specification: String -administrator: String=“Unspecified” Figure 4. 6 A class with attributes and their default values UML (Use-Case Modeling), Dr. Chen TM -23

Invoice +amount : Real +date: Date=Current date +customer: String -number_of_invoices: integer = 0 Public

Invoice +amount : Real +date: Date=Current date +customer: String -number_of_invoices: integer = 0 Public class Invoice { public double amount; public Date date = new Date(); public String customer; static private int number_of_invoices = 0; //Constructor, called every time an objects is created public Invoice () { // Other Initialization number_of_invoices++; //Increment the class attributes } // Other methods go here }; Figure 4. 9 An Invoice class UML (Use-Case Modeling), Dr. Chen TM -24

Car + registration number: String + data: Car. Data + speed: integer + direction:

Car + registration number: String + data: Car. Data + speed: integer + direction: Direction + drive (speed: integer, direction: Direction) + get. Data() : Car. Data Figure 4. 10 The car has attributes and operations. The operation drive has two parameters, speed and direction. The operation get. Data has a return type, Car. Data. UML (Use-Case Modeling), Dr. Chen TM -25

Associations: Normal Association Author Uses Computer Figure 4. 15 An author uses a computer

Associations: Normal Association Author Uses Computer Figure 4. 15 An author uses a computer The author class has an association to the Computer class. UML (Use-Case Modeling), Dr. Chen TM -26

Person 1. . * Owns Owned by 0. . * Car Figure 4. 16

Person 1. . * Owns Owned by 0. . * Car Figure 4. 16 A person owns many (zero-to-many) cars, A car can be owned by many (one-to-many) persons. UML (Use-Case Modeling), Dr. Chen TM -27

Owns Person 0. . * Car Figure 4. 17 A navigable association says that

Owns Person 0. . * Car Figure 4. 17 A navigable association says that a person can own many cars, but it does not say anything about how many people can own a car. UML (Use-Case Modeling), Dr. Chen TM -28

Insurance policy 1 has 0. . * refer to Expressed an Insurance company 0.

Insurance policy 1 has 0. . * refer to Expressed an Insurance company 0. . 1 is expressed in an Web Insurance policy 0. . 1 Insurance contract 0. . * has refer to 1. . * Figure 4. 18 A class diagram describing an insurance business UML (Use-Case Modeling), Dr. Chen Customer TM -29

Author Computer name : String age: Integer name : String money: Integer 0. .

Author Computer name : String age: Integer name : String money: Integer 0. . * 1. . * Bob’s PC COMPUTER Bob: Author name : String money: Integer name : String age: Integer 0. . * 1. . * Figure 4. 19 A class diagram and an object diagram and an example of the class diagram being instantiated UML (Use-Case Modeling), Dr. Chen TM -30

Recursive Association Person Node Connects married to Figure 4. 20 A network consists of

Recursive Association Person Node Connects married to Figure 4. 20 A network consists of many nodes connected to each other. UML (Use-Case Modeling), Dr. Chen TM -31

Insurance company 1 contracts refer to 0. . * Insurance contract Figure 4. 22

Insurance company 1 contracts refer to 0. . * Insurance contract Figure 4. 22 Insurance company has associations to Insurance contract UML (Use-Case Modeling), Dr. Chen TM -32

Another example of Roles in Association Car * drives company car * driver Person

Another example of Roles in Association Car * drives company car * driver Person Figure 4. 24 What roles do Person and Car play in this association? UML (Use-Case Modeling), Dr. Chen TM -33

Roles in Association wife Person husband married to Figure 4. 25 A husband is

Roles in Association wife Person husband married to Figure 4. 25 A husband is married to a wife. Both husband wife are people. If a person is not married, then he or she cannot play the role of husband or wife, which means that the married to association is no applicable. UML (Use-Case Modeling), Dr. Chen TM -34

Ready for the Next Run? UML (Use-Case Modeling), Dr. Chen TM -35

Ready for the Next Run? UML (Use-Case Modeling), Dr. Chen TM -35

Insurance policy Roles in an Association Expressed an Insurance company 1 insurer has 0.

Insurance policy Roles in an Association Expressed an Insurance company 1 insurer has 0. . * refer to UML (Use-Case Modeling), Dr. Chen 0. . * 1. . * wife has different roles in different associations. The model from Figures 4. 18 and 4. 25 are combined. In this model, a person can play the role of husband, wife, or policyholder. The insurance company plays the insurer role. Insurance contract refer to Figure 4. 26 A class can play is expressed in an 0. . 1 policyholder Person husband married to TM -36

An example for Qualified Association Directory UML (Use-Case Modeling), Dr. Chen * * *

An example for Qualified Association Directory UML (Use-Case Modeling), Dr. Chen * * * file name File TM -37

Or-Association Insurance company 1 0. . * Insurance contract 0. . * 1. .

Or-Association Insurance company 1 0. . * Insurance contract 0. . * 1. . * Person 1. . * Company Figure 4. 28 An insurance contract cannot have associations to both company and person at the same time UML (Use-Case Modeling), Dr. Chen TM -38

Or-Association Insurance company 1 0. . * Insurance contract 0. . * 1. .

Or-Association Insurance company 1 0. . * Insurance contract 0. . * 1. . * Person 0. . * or 1. . * Company Figure 4. 29 An or-association shows that only one of the associations is valid at a time UML (Use-Case Modeling), Dr. Chen TM -39

Or-Association Insurance company 1 has insurer refer to 0. . * Insurance contract 0.

Or-Association Insurance company 1 has insurer refer to 0. . * Insurance contract 0. . * wife Results of Figures 4. 26, 28, and 29: An insurance contract cannot have associations to both company and person at the same time UML (Use-Case Modeling), Dr. Chen or has 1. . * refer to 0. . * policyholder Person 1. . * Company 1. . * husband married to TM -40

Insurance 1 company insurer 0. . * Insurance contract 0. . * 0. .

Insurance 1 company insurer 0. . * Insurance contract 0. . * 0. . 1 1. . * Insurance policyholder Person Figure 4. 32 A ternary association connects three classes. UML (Use-Case Modeling), Dr. Chen TM -41

Teams * * Person Members Figure 4. 34 A team is composed of team

Teams * * Person Members Figure 4. 34 A team is composed of team Members. One person could be a member of many teams. The model shows an example of a shared aggregation, where the people are the shared parts. UML (Use-Case Modeling), Dr. Chen TM -42

* * Window * * Text Listbox Button Menu Figure 4. 36 The diamond

* * Window * * Text Listbox Button Menu Figure 4. 36 The diamond shows the composition aggregate; the window contains ( is aggregated of) many menus, buttons, listboxes, and texts. All types of aggregation can have a name. UML (Use-Case Modeling), Dr. Chen TM -43

* * Window Text Listbox Contains * * Button Menu Figure 4. 37 If

* * Window Text Listbox Contains * * Button Menu Figure 4. 37 If there is more than one part in the same aggregate (wholeside into a single end. This is allowed for all types of aggregates. An aggregate has only one role name, and that is at the partside. UML (Use-Case Modeling), Dr. Chen TM -44

Vehicle CAR Boat Truck Figure 4. 41 Vehicle is a general class (superclass) derived

Vehicle CAR Boat Truck Figure 4. 41 Vehicle is a general class (superclass) derived to specific classes (subclasses) via inheritance (generalization-specialization). UML (Use-Case Modeling), Dr. Chen TM -45

Vehicle CAR Boat Truck Figure 4. 42 The same model as in Figure 4.

Vehicle CAR Boat Truck Figure 4. 42 The same model as in Figure 4. 41, but the inheritance takes the form of a tree (with only one hollow triangle). UML (Use-Case Modeling), Dr. Chen TM -46

Vehicle CAR Boat Vehicle Truck CAR Boat Truck Figure 4. 43 A class hierarchy

Vehicle CAR Boat Vehicle Truck CAR Boat Truck Figure 4. 43 A class hierarchy for vehicles. The Car class is subclass to Vehicle, but superclass to Sports car, Passenger car, and Truck. UML (Use-Case Modeling), Dr. Chen TM -47

Figure 4. 44 Vehicle {abstract} The Car inherits the attribute color and the operation

Figure 4. 44 Vehicle {abstract} The Car inherits the attribute color and the operation drive. The operation drive is redefined in the class Car and Boat. The class Vehicle is abstract, which also is marked. The notes below the classes are used to comment on a class diagram Drive() {abstract} Car Boat drive() starts the wheels UML (Use-Case Modeling), Dr. Chen drive() starts thepropeller TM -48

Person drives Figure 4. 45 A person drives vehicles. When the drive operation is

Person drives Figure 4. 45 A person drives vehicles. When the drive operation is called, the implementation used depended on whether the object used is a car or a boat. Vehicle is an abstract class showing the commonalties between cars and boats, including the association relationship to the Person class UML (Use-Case Modeling), Dr. Chen * Vehicle {abstract} color drive() {abstract} Car Boat drive() TM -49

Vehicle {abstract} drive() {abstract} Propulsion Car Boat drive() Figure 4. 47 Generalization-specialization with a

Vehicle {abstract} drive() {abstract} Propulsion Car Boat drive() Figure 4. 47 Generalization-specialization with a discriminator that specifies that it is with respect to the propulsion that the subclass differ. UML (Use-Case Modeling), Dr. Chen TM -50

Object vs. Function-Oriented Analysis and Design (Structured Analysis and Design) The Library Information system

Object vs. Function-Oriented Analysis and Design (Structured Analysis and Design) The Library Information system Object-oriented A/D Decomposed by objects or concepts Catalogue Librarian Book Library UML (Use-Case Modeling), Dr. Chen Structured A/D Decomposed by functions or processes System Record Loans Add Resource Report Fines TM -51

Figure: Conventional vs. Object - Oriented Conventional Decomposed Functions/process by Types Data type (e.

Figure: Conventional vs. Object - Oriented Conventional Decomposed Functions/process by Types Data type (e. g. ) int num_of_employees Content One variable contains one value. e. g. number_of _employees =20 UML (Use-Case Modeling), Dr. Chen Object-Oriented Objects/concepts Class type class employee … } employee full-time, part-time; One class contains many objects One object has many attributes, operations TM -52