Presentation is loading. Please wait.

Presentation is loading. Please wait.

Domain Modeling Yonglei Tao.

Similar presentations


Presentation on theme: "Domain Modeling Yonglei Tao."— Presentation transcript:

1 Domain Modeling Yonglei Tao

2 Classes and Objects in UML

3 Representing Type in UML
SSN: String checkin(time:float):void name: String checkout(time:float):void Employee

4 Associations

5 Multiplicity

6 Associations

7 Inheritance User Staff Student id: String name: String
login(id, password) logout() Staff Student processApplication() applyOnline()

8 Rules for Inheritance A subclass is a (kind of) superclass
A superclass is more general than a subclass 100% of the superclass’s definition should be applicable to the subclass Attributes Associations

9 Is-A Relationship

10 Two Tests for Inheritance
IS-A test: every instance of a subclass is also an instance of the superclass. Conformance test: relationships of a superclass are also relationships of subclasses. Engine model# horse power manufacturer start() stop() Car drive() Professor name phone teach(...) Visiting Professor signContract() Retirement Plan enroll Car is not an engine. Visiting professors cannot enroll in a retirement plan at the host university.

11 Creating a Subclass Include additional features of interest
attributes associations Include different behavior add new operations redefine superclass operations Support software reuse (with modification)

12 Creating a Superclass Factor out common features among subclasses
common attributes, associations, and behavior code sharing Allow potential subclasses representing variations of a similar concept provide a common interface support polymorphic processing

13 Justifying a Class Hierarchy

14 Abstract Class Represents a class that never has any concrete instances Defines an interface for related subclasses Every member of the class must also be a member of a subclass

15 Abstract Classes

16 Aggregation Relationship
Car model# horse power manufacturer start() stop() Engine part-of relationship

17 Composite Relationship

18 Part-Of Relationships
Composite the whole solely owns the parts the part’s lifetime is bound within the lifetime of the whole certain properties of the whole propagate to the parts Aggregation logical assembly the parts can be referenced by one or more wholes

19 Why Composition? Help determine the lifetime of a object
a create-delete dependency of the part on the whole Help identify an object creator Provide a way of grouping hide parts within the whole

20 Association Classes

21 Association Class An association class defines properties and operations for an association between two classes. Student Course enroll * Enroll grade: char getGrade() setGrade(grade:char)

22 Understand Association Class
Alex got an “A” and Eric got a “B” for OOSE. :Enroll ‘A’: char getGrade() setGrade() Alex:Student OOSE:Course enroll ‘B’: char Eric:Student :Enroll ‘A’: char getGrade() setGrade() Alex:Student AI:Course enroll Alex also got an “A” for AI.

23 Understand Association Class
class Student { ... } class Course {...} class Enroll { private char grade; private Student student; private Course course; public Enroll (Student s, Course c) { student=s; course=c; } public char getGrade() {…} public void setGrade(char grade) {…} Implementation Student enroll Course Enroll grade: char getGrade() setGrade(grade:char) Student alex=new Student( ... ); Course oose=new Course ( ... ); ... Enroll e=new Enroll(alex, oose); e.setGrade(‘A’);

24 Understand Association Class
Student Course sid phone ... name cn desc title Enroll grade 001 Alex 002 Eric c1 oose c2 AI A B Enroll grade: char getGrade() setGrade(grade:char) Student Course enroll

25 Constraints

26 Steps for Domain Modeling
1) Collecting application domain information focus on the functional requirements also consider other requirements and documents also consider business descriptions 2) Brainstorming list important application domain concepts list their properties/attributes list their relationships

27 Steps for Domain Modeling (Cont.)
3) Classifying the domain concepts into: classes attributes / attribute values relationships association, inheritance, aggregation 4) Visualizing the result using a UML class diagram

28 Brainstorming: Rules to Apply
Team members get together to identify and list domain specific concepts nouns / noun phrases "X of Y" expressions (e.g., color of car) transitive verbs adjectives numeric possession expressions (has/have, possess, etc.) "constituents / part of" expressions containment / containing expressions "X is a Y" expressions

29 Identify Important Concepts
“An undergraduate student or a graduate student can apply to no more than two exchange programs per semester. An application consists of an application form, two faculty recommendation letters, and a course equivalent form to be approved by an academic advisor.” … “An exchange program has program name, program type, academic department, academic subject, country, region, term of study, and language.”

30 Classifying Brainstorming Result
nouns/noun phrases "X of Y" expressions transitive verbs adjectives numeric possession expressions (has/have, possess, etc.) "consist of/part of" expression containment / containing expressions "X is a Y" expressions class or attributes X is an attribute of Y X is part of Y X is a role in an association association relationships attribute values attribute / multiplicity values aggregation or attribute aggregation relationships association or aggregation inheritance

31 Examples Domain specific nouns/noun phrases transitive verbs
exchange program semester undergraduate student Domain specific nouns/noun phrases apply to (programs) transitive verbs Rule: transitive verbs Þ association relationships Rule: noun/noun phrase  class or attribute Because they exist independently in the application domain.

32 A car has make, model, horse power, number of seats ...
numeric noun/noun phrases A car has make, model, horse power, number of seats ... possession expression (c) car (a) make (a) model (a) horse power (a) number of seats Car has independent existence. Make, model, horse power, and number of seats do not. A customer can rent one or more cars ... (c) customer (c) car rent 1+

33 Visualizing in a Class Diagram

34 Class Exercise Do the following for the vending machine (next slide).
Identify the concepts that exist in the application domain. Classify the concepts in terms of classes attributes of classes relationships between the classes inheritance aggregation and association

35 Class Exercise: The Vending Machine
The Vending Machine has a display, an alphanumeric keypad, a coin insertion slot, and an item dispenser. The display shows the vending items like chocolates, candies, potato chips, Coke, sprite, etc. Each type of item has a price and a label consisting of a letter A, B, C, ... and a digit 1, 2, ... A customer inserts coins through the coin slot. Each time a coin is inserted an LCD displays the total amount. The customer can press a letter and a digit to enter his selection after enough coins have been inserted. If the total amount is greater than or equals to the item selected, the vending machine dispenses the item and returns the change to the customer. A customer can change his mind and request that the coins be returned by pressing the return button.


Download ppt "Domain Modeling Yonglei Tao."

Similar presentations


Ads by Google