Software Engineering Chapter 5 Part 2 System Modeling

  • Slides: 54
Download presentation
Software Engineering Chapter 5 (Part 2) System Modeling Dr. Doaa Sami Modified from Sommerville’s

Software Engineering Chapter 5 (Part 2) System Modeling Dr. Doaa Sami Modified from Sommerville’s originals

2 C. Structural Models

2 C. Structural Models

What is a Domain Model? ● Use cases looked at the system’s environment (actors)

What is a Domain Model? ● Use cases looked at the system’s environment (actors) and the system’s external behavior. ● Use cases consider the system as a black box and help us understand how the system as a whole interacts with the outside word. ● Now we turn to consider the inside of the system. We do this by building the domain model, which shows what the black box (the system) encloses. ● uses cases elaborate the system’s behavioral characteristics (sequence of stimulus-response steps), ● domain model gives details of the systems structural characteristics (system parts and Software Engineering OO Domain Modeling

What is a Domain Model? ● uses cases elaborate the system’s behavioral characteristics (sequence

What is a Domain Model? ● uses cases elaborate the system’s behavioral characteristics (sequence of stimulus-response steps), ● domain model gives details of the systems structural characteristics (system parts and their arrangement) ● The next step is to model the inside of the system. We do this by building the domain model, which shows what the black box (the system) encloses. Software Engineering OO Domain Modeling

3 1. C l a s s D i a g r a m

3 1. C l a s s D i a g r a m

Structural Models 4 Structural models of software display the organization of a system in

Structural Models 4 Structural models of software display the organization of a system in terms of the components that make up that system and their relationships. You create structural models of a system when you are discussing and designing the system architecture. Class diagrams used for modeling the static structure of the object classes in a software system.

Class Diagram 5 A class represent a concept. It is a description of a

Class Diagram 5 A class represent a concept. It is a description of a set of objects having similar attributes, operations, relationships and behaviors. A class encapsulates state (attributes) and behavior (operations). The Class Name is the only mandatory information. Class Name Attribute Operation()

From Use Cases to: Objects, Attributes, Operations (methods) -“evolutionary ” Software Engineering OO Domain

From Use Cases to: Objects, Attributes, Operations (methods) -“evolutionary ” Software Engineering OO Domain Modeling

Building the Domain Model A useful strategy for building a domain model is to

Building the Domain Model A useful strategy for building a domain model is to start with: ● the “boundary” concepts that interact directly with the actors ● and then identify the internal concepts Software Engineering OO Domain Modeling

Domain Model Relationships Conceptual Class Diagram Classes, attributes, associations Domain objects Domain Model Define

Domain Model Relationships Conceptual Class Diagram Classes, attributes, associations Domain objects Domain Model Define terms Glossary Use Case Model Functional Requirements Interaction Diagrams Dynamic Behavior Software Engineering OO Domain Modeling

Steps to create a Domain Model Steps ● Identify Candidate Conceptual classes ● Draw

Steps to create a Domain Model Steps ● Identify Candidate Conceptual classes ● Draw them in a Domain Model ● Add associations necessary to record the relationships that must be retained ● Add attributes necessary for information to be preserved Software Engineering OO Domain Modeling

Finding Classes 6 Categories to focus when finding represent-able objects: Tangibles (e. g. classroom,

Finding Classes 6 Categories to focus when finding represent-able objects: Tangibles (e. g. classroom, playground). Conceptual (e. g. course, module). External Organizations (e. g. publisher, supplier). Roles Played (student, teacher). Other System (admission system, grade reporting system).

Class Attributes 7 Visibility name : type [count] = default_value underline static attributes. Visibility

Class Attributes 7 Visibility name : type [count] = default_value underline static attributes. Visibility + public # protected - private / derived attribute: not stored, but can be computed from other attribute values Student -name: string - salary: double - total. Student: int + get. Name(): string + get. Salary(): double + get. Total. Studen()t: int Rectangle -length: double -width: double /area: double +getlength(): double +get. Width(): double +get. Area(): double

Class Operations 8 Visibility name (parameters) : return_type underline static operations. Visibility + public

Class Operations 8 Visibility name (parameters) : return_type underline static operations. Visibility + public # protected - private return_type is omitted if function is: constructor void Student -name: string - salary: double - total. Student: int + get. Name(): string + get. Salary(): double + get. Total. Studen()t: int Rectangle -length: double -width: double /area: double +getlength(): double +get. Width(): double +get. Area(): double

Attributes: UML Notation Software Engineering OO Domain Modeling

Attributes: UML Notation Software Engineering OO Domain Modeling

Find conceptual classes Software Engineering OO Domain Modeling

Find conceptual classes Software Engineering OO Domain Modeling

Use a category list ● Finding concepts using the concept category list : ●

Use a category list ● Finding concepts using the concept category list : ● Physical objects: register, airplane, blood pressure monitor ● Places: airport, hospital ● Catalogs: Product Catalog ● Transactions: Sale, Payment, reservation Software Engineering OO Domain Modeling

Identifying objects Software Engineering OO Domain Modeling

Identifying objects Software Engineering OO Domain Modeling

Identifying Operations ‘methods’ Software Engineering OO Domain Modeling

Identifying Operations ‘methods’ Software Engineering OO Domain Modeling

Objects Software Engineering OO Domain Modeling

Objects Software Engineering OO Domain Modeling

Example: Identify conceptual classes from noun phrases Consider the following problem description, analyzed for

Example: Identify conceptual classes from noun phrases Consider the following problem description, analyzed for Subjects, Verbs, Objects: The ATM verifies whether the customer's card number and PIN are correct. R O SC V OA OA If it is, then the customer can check the account balance, deposit cash, and withdraw cash. SR V OA Checking the balance simply displays the account balance. SM OA V OA Depositing asks the customer to enter the amount, then updates the account balance. M S V OR V OA Withdraw cash asks the customer for the amount to withdraw; if the account has enough cash, S M AO V OR OA V SC V OA the account balance is updated. The ATM prints the customer’s account balance on a receipt. OA V V OA O C S Analyze each subject and object as follows: ● Does it represent a person performing an action? Then it’s an actor, ‘R’. ● Is it also a verb (such as ‘deposit’)? Then it may be a method, ‘M’. ● Is it a simple value, such as ‘color’ (string) or ‘money’ (number)? Then it is probably an attribute, ‘A’. ●Which NPs are unmarked? Make it ‘C’ for class. Verbs can also be classes, for Software Engineering OO Domain Modeling example:

Mapping parts of speech to object model components [Abbott, 1983] Part of Speech Proper

Mapping parts of speech to object model components [Abbott, 1983] Part of Speech Proper noun Model Component Instance Common noun Class Doing verb Operation Being verb Inheritance Is a kind of, is one of either Having verb Aggregation (Compositio n) Constraints Has, consists of, includes Modal verb Adjective attributes Attributes Software Engineering Examples Ali Student, Customer, . . Buy, check, . . Must be 3 years old OO Domain Modeling

Example: a typical description Software Engineering OO Domain Modeling

Example: a typical description Software Engineering OO Domain Modeling

Mapping parts of speech to object model components Software Engineering OO Domain Modeling

Mapping parts of speech to object model components Software Engineering OO Domain Modeling

Example: Initial POS domain model Sales. Line. Item Sale Software Engineering Register Payment Item

Example: Initial POS domain model Sales. Line. Item Sale Software Engineering Register Payment Item Store OO Domain Modeling

Relationships 9 There are two kinds of Relationships Association (student enrolls in course). Generalization

Relationships 9 There are two kinds of Relationships Association (student enrolls in course). Generalization (parent-child relationship). Associations can be further classified as Aggregation. Composition.

Associations Software Engineering OO Domain Modeling

Associations Software Engineering OO Domain Modeling

Association 10 Associations denote relationships between classes. Describe the nature of the relationship. Example:

Association 10 Associations denote relationships between classes. Describe the nature of the relationship. Example: Student enrolls into course Course enrolled by a student. Student Course Enrolls

Multiplicity 11 Multiplicity is the number of instances one class relates to ONE instance

Multiplicity 11 Multiplicity is the number of instances one class relates to ONE instance of another class. For each association, there are two multiplicity decisions to make, one for each end of the association. For each instance of Professor, many Sections may be taught. For each instance of Section, there may be either one or zero Professor as the instructor. Professor -name: string +get. Name(): string Section 0. . 1 has 0. . * -section#: int +get. Section#: int

Multiplicity (C++ Implementation) 12 Professor -name: string Section 0. . 1 has 0. .

Multiplicity (C++ Implementation) 12 Professor -name: string Section 0. . 1 has 0. . * -section#: int +get. Name(): string +get. Section#: int class Professor{ // A list of Sections Section sec[4]; string name; Public: string get. Name(); }; class Section{ // Proffessor Professor prof; int section. Num; Public: int get. Section. Num(); } ;

Multiplicity Representation 13

Multiplicity Representation 13

Multiple association between two classes Software Engineering OO Domain Modeling

Multiple association between two classes Software Engineering OO Domain Modeling

Example: Initial POS domain model Software Engineering OO Domain Modeling

Example: Initial POS domain model Software Engineering OO Domain Modeling

Example: Initial Domain model of the Monopoly Game Software Engineering OO Domain Modeling

Example: Initial Domain model of the Monopoly Game Software Engineering OO Domain Modeling

Example: Domain model of the Monopoly Game Software Engineering OO Domain Modeling

Example: Domain model of the Monopoly Game Software Engineering OO Domain Modeling

Aggregation 14 Association is used when both of the involved classes are equaly important.

Aggregation 14 Association is used when both of the involved classes are equaly important. Aggregation is a special form of association that models a whole-part relationship between an aggregate (the whole) and its parts. Aggregation shows how classes that are collections are composed of other classes. Aggregation is a part-of relationship. Car 1 4 Wheel

Composition 15 Aggregation is used to model a whole-part relationship between an aggregate (whole)

Composition 15 Aggregation is used to model a whole-part relationship between an aggregate (whole) and its parts. Composition is a strong form of aggregation. The whole is the only owner of its part. Multiplicity on the whole side must be one. The lifetime of the part is dependent upon the whole. When Circle is destroyed, Point is also destroyed. The composite must manage the creation and destruction of its parts.

Composition (C++ Implementation) 16 Restaurant class Restaurant{ Menu m; . . }; 1 1

Composition (C++ Implementation) 16 Restaurant class Restaurant{ Menu m; . . }; 1 1 Menu class Menu{. . };

Generalization 17 Rather than learn the detailed characteristics of every entity that we experience,

Generalization 17 Rather than learn the detailed characteristics of every entity that we experience, we place these entities in more general classes (animals, cars, houses, etc. ) and learn characteristics of these classes. This allows us to infer that different members of these classes have some common characteristics e. g. Cows and Wolfs are Mammals.

Generalization Cont. 18 In object-oriented languages, generalization is implemented using class inheritance mechanisms. In

Generalization Cont. 18 In object-oriented languages, generalization is implemented using class inheritance mechanisms. In a generalization, the attributes and operations associated with higher-level classes (super classes) are also associated with the lower-level classes (sub classes). Subclasses are inherit the attributes and operations from their Superclasses and then add more specific attributes and operations.

Generalization 19

Generalization 19

Generalization Software Engineering OO Domain Modeling

Generalization Software Engineering OO Domain Modeling

Association Class 20 An association class is a construct that allows an association connection

Association Class 20 An association class is a construct that allows an association connection to have operations and attributes. It used when you need to include another class because it includes valuable information about the relationship.

Example: Information System for School 21

Example: Information System for School 21

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Software Engineering OO Domain Modeling

Class or Attributes Software Engineering OO Domain Modeling

Class or Attributes Software Engineering OO Domain Modeling

Class or Attributes Software Engineering OO Domain Modeling

Class or Attributes Software Engineering OO Domain Modeling

Description Class Software Engineering OO Domain Modeling

Description Class Software Engineering OO Domain Modeling

Data types as attributes Software Engineering OO Domain Modeling

Data types as attributes Software Engineering OO Domain Modeling

Attributes are NOT foreign keys Software Engineering OO Domain Modeling

Attributes are NOT foreign keys Software Engineering OO Domain Modeling