You are on page 1of 115

CHNG IV

Biu lp

Phn tch Thit k HT

UML

Ni dung
1. Phng php hng i tng
1. Phng h h 1 Ph php hng i tng? t ? 2. Xc nh i tng

2. Biu 2 Bi lp l
1. Biu lp? 2. Biu di 2 Bi din quan h ( l ti (relationship) hi )

1. Phng php hng i tng


Phn tch Thit k HT

Structured
Account aNo balance Account ER DFD with Data Store Structure Chart amount message withdraw ithd amount withdrawal message

OO approach
Objects

MyAccount aNo= 101 balance=500 balance( ) withdraw( ) --3

withdraw(X) ( )

:MyAccount

Nguyn l c bn

Object Orientation Obj t O i t ti

Encapsulat tion

Ab bstractio on

Mo odularit ty

Hierarchy y

Nhng thuc tnh c bn


Phn tch Thit k HT

Data and operations Encapsulation Classes and objects Generalisation/Specialisation

+ =

Polymorfism y Object-orientation (OO)

S tru tng (Abstraction)?

Salesperson Not saying Which salesperson j just a salesperson in general!!! Customer Product

Manages Complexity M C l it
6

Tnh ng gi (Encapsulation)?
Phn tch Thit k HT

Che du vic thc thi (tnh mm do)


Clients depend on interface

How does an object encapsulate? What does it encapsulate?

Improves R ili I Resiliency


7

Tnh ng gi
Phn tch Thit k HT

easy to use (d dng)

-3 advantages ? )

more reliable (tin cy) less coupling (lin kt thp)

Account aNo balance balance( ) withdraw( ) ---

Name of Class Data


(usually hidden)

balance(?) withdraw(X)
My Account:: aNo=101 balance=300

Methods (usually interface)

Giao tip qua interface (giao din)


Phn tch Thit k HT

Manufacturer A

Manufacturer B

Manufacturer C

Polymorfism

Tnh phn on (Modularity)?


Phn tch Thit k HT

Order Entry Order Processing System Order Fulfilment (thc hin)

Billing Manages Complexity


10

H thng cp bc (Hierarchy)?
Phn tch Thit k HT

Asset
Increasing abstraction

BankAccount

Security

RealEstate

Savings Checking Stock


Decreasing abstraction b t ti

Bond

Nhng thnh phn cng mc phn cp s cng mc tru tng


11

Xc nh i tng
Phn tch Thit k HT

Object Class Cl Attribute Operation Relationships Interface (Polymorphism)

12

i tng (Object)
Phn tch Thit k HT

Rumbaugh et al. (1991)

We d fi W define an object as a concept, abstraction, bj t t b t ti or thing with crisp boundaries and meaning for the problem at hand. Objects serve two purposes:
they promote understanding of the real world they provide a practical basis for computer implementation.
Not every modeller may agree on the choice, meaning, and sometimes the need for tangible and intangible objects.

i tng ?
Phn tch Thit k HT

Thc th vt l Thc th khi nim Thc th phn mm


Chemical Process

Truck

Linked List

14

i tng
Phn tch Thit k HT

Mt i tng l mt khi nim, mt s tru tng hay t h l mt s vt (thi ) c ranh gii r t t (thing) h ii rng v c ngha cho mt ng dng Mt i tng c
Trng thi (State) Hnh vi (Behavior) nh danh (Identity)

15

Object
Phn tch Thit k HT

Relational databases
Sven Lund

Data modelling

Olle Macho

Feelings
Anna Lind Ulla Rask

Project management

Erik Gadd

Students

A thing can be either concrete or abstract.

Courses

An object is an instance of a thing thing.

An object is something, we something want to hold information about.

Biu din i tng


Phn tch Thit k HT

: Professor
a + b = 10

ProfessorClark
Class Name Only
Professor Clark

ProfessorClark : Professor

Object Name Only

Class and Object Name


17

V d mt i tng
Phn tch Thit k HT

Coffee machine
Bl k coffee Black ff Coffee with sugar Coffee with cream Coffee with cream and sugar

Class Cl Coffee machine Attributes ... Operations


Black coffee Coffee with sugar g Coffee with cream Coffee with cream and sugar ...

Study case: Xc nh i tng (1)


Phn tch Thit k HT

We have a family with a father (John), a mother (Jane), two sons (Peter and Paul), and two daughters (Elizabeth and Mary). John is a businessman and works for Ericsson Radio System. Jane is a lecturer and works at Stockholm System University. All the children are students at Stockholm University. Peter studies Polish, Paul studies statistics, Elizabeth studies computer science and Mary studies Russian. The family has a dog called Jaruzelski and Peter y y g has a friend Krzysztof from Poland. Recently, Ericsson have realised that Poland is going to be a prosperous market for their products. Hence, they ordered John to study Polish. They believe that the knowledge of Polish will substantially improve business b li th t th k l d f P li h ill b t ti ll i b i relationships between Ericsson and some Polish companies. Hence, John has just started learning Polish at ABF. Two days ago, John was assigned a task to write a letter to one Polish company called Polska Telekomunikacja. John realised that he cannot write this letter, not yet. His Polish is not good enough. Therefore, he asked his son Peter whether he might write this letter. John would write the letter in Swedish, d P t S di h and Peter would translate it to Polish. ld t l t t P li h

Study case: Xc nh i tng (2)


Phn tch Thit k HT

He would pay 1000 SEK to Peter for this help. Peter agrees and says that he will translate this letter. The translation should be finished by this evening. In the afternoon, Peter comes from his lectures and is exhausted from a long day at university. When reading Johns letter, he realises that his Polish is not good enough. He must look up too many words in a Swedish-Polish dictionary. This would require more than 6 hours. He decides to ask Krzysztof to do the translation for him. Krzysztof agrees to do the translation. He does it within 30 minutes. Krzysztof does it as a favour. He refuses to accept money from Peter. Krzysztof pleases himself with Dziekuje in Polish, hi h P li h which means Thank you. Th k Later that evening, John comes home, gets Peters translation and pays him money. He also reads the letter, and things that Peter has done a wonderful j b Hence, he complements Peter on P t h d d f l job. H h l t P t his professionalism.

Xc nh i tng
Phn tch Thit k HT

Object Class Cl Attribute Operation Relationships Interface (Polymorphism)

21

Lp (Class)?
Phn tch Thit k HT

Mt lp l m t ca mt nhm i tng vi thuc tnh ( th t h (properties - attributes) chung, h h vi ti tt ib t ) h hnh i (behavior - operations), quan h (relationships), v ng ngha (semantics)
Mt i tng l mt th hin (instance) ca mt lp

Mt lp l mt s tru tng trong n:


Nhn mnh n nhng c tnh chung B qua nhng c tnh ring bit

OO Principle: Abstraction
22

Lp kha hc
Class Course
Properties Name Location Days offered Credit hours Start time End time Behavior Add a student Delete a student Get course roster Determine if it is full

a + b = 10

23

Biu din lp
Phn tch Thit k HT

Professor

a + b = 10

Professor Clark

Class Name Attributes (tc) Operations (hv)

Professor name empID create( ) save( ) delete( ) change( )


24

Study case: Xc nh lp (1)


Phn tch Thit k HT

We need write an application supporting us in managing the information about university operation Right now, at operation. now Stockholm University we have a substantial amount of students - 35 000 students. To manually manage all information abo t st dents simpl impossible Hence info mation about students is simply impossible. Hence, SU needs some automated support. In addition to this, we need handle information on courses and lecturers giving these courses. Recently, SU has taken over the library and book shops. They want to provide better service to their students and students, they want to better integrate the management of course literature with all other courses given at SU. Hence, they wish to automate the book management as well.

Study case: Xc nh lp (2)


Phn tch Thit k HT

This gives them better insight into the education on the course level and provides a solid basis for evaluating the level, courses and a basis for establishing the incremental educational programme. The knowledge of which books are utilised on which course helps them identify the overlapping in the educational material. To be able to provide high quality education SU must have education, highly competent lecturers. SU wishes to store information about their lecturers and their state of competence and its development. d l t

SC: Biu lp
Phn tch Thit k HT

Student

Lecturer

Book shop

Course Book B k

Competence Evaluation

Course Evaluation

Library Course Overlapping O l i Competence

University

Do we need a class called University?

Xc nh i tng
Phn tch Thit k HT

Object Class Cl Attribute Operation Relationships Interface (Polymorphism)

28

Thuc tnh (Attribute) ?


Class Attribute Object Attribute Value

:CourseOffering
number = 101 b startTime = 900 endTime = 1100

CourseOffering
number startTime endTime

:CourseOffering
number = 104 startTime = 1300 endTime = 1500

29

Thuc tnh v trng thi


Phn tch Thit k HT

Course
course_number: String course_name: course name: String no_of_students: Integer teacher_name: String

State 1 Polish: Course


PPP234 Polish 12 Adamski

State 2 Polish: Course


PPP234 Polish 34 Szczyperski

State 3 Polish: Course


PPP234 Polish 34

When an attribute value changes, the object itself changes states.

Tm thuc tnh
Phn tch Thit k HT

i tng c m t tn q nh th no ? g qut Phn no trong m t tng qut c th p dng cho lnh vc quan tm ? M t ti gin cn thit cho ng dng s nh th no ?

Che du thng tin


Phn tch Thit k HT

Class: Person
name() age() address() pnr: Integer name: String birth_date: Integer address: String change_address(new_address) change address(new address)

Class: Student

Change_address (Tjdervgen .)

changes data

David Parnas the founder of OO

requires service

Class: Student

Only the objects own code may read and change its own data l d t values.

Change_address (Tjdervgen .)

Tnh kh kin
Phn tch Thit k HT

Person - pnr: Integer - name: String - birth_date: Integer - address: String g


+ name() + age() - count age() + address() dd () + change_address(new_address)

In UML, the visibility is normally designated by a plus or minus symbol: + for public visibility - for private visibility

Not only the attributes are hidden hidden. Operations may be hidden as well.

Case Study: xc nh thuc tnh (1)


Phn tch Thit k HT

At SU, many students come from all over the world. So, SU does not only need store information about the student names, addresses, but also information about their nationalities, translations of their degrees and so on. Due to the fact that it is impossible to uniquely identify students by name, SU needs some kind of a unique identifier for each student. The automatic Object ID supplied by the system is not enough. One needs a more mnemotechnic identifier to be managed by people. Hence, one people Hence decides to use Swedish personal number as an identifier. Some courses require that the students undergo special IQ - tests. These courses are often very expensive. Hence, only the best students may attend them. It is not enough that they have good high school grades. They must also undergo an especially designed IQ-test. The results of this test are stored in the SU application. Recent studies have shown that there are too many old students at SU. SU The average age right now is 45. Hence, social democrats started a campaign to make younger people get more interested in university studies. To find out whether the campaign g p g gives some results, the , Swedish politicians require that SU regularly compiles the average age of the students.

Case Study: xc nh thuc tnh (2)


Phn tch Thit k HT

Concerning the lecturers, SU needs to store the basic personal data such as name, address, the job role (lecturer, advisor, course developer), developer) and also qualifications (pedagogical, administrative, and (pedagogical administrative professional subject-related competence). In addition to this, one needs information whether the lecturer works full-time or part-time, how much he earns, whether he/she is married, and whether she/he does active research. Concerning the courses, we need to uniquely identify the course with some identifier, we must have the course name and course description. In addition to this, we must make some restrictions on the number of students on the course. Some of the courses require audio-visual equipment; hence, they must be conducted in q p y especially equipped rooms having a limited number of seats. Finally, one must know, which lecturer teaches on which course. Regarding the books, we must have some kind of an identifier and g g title. We must also know their price and on which course they are being utilised.

Case Study: thuc tnh


Phn tch Thit k HT

Student St d t
pnr: Integer student_name: String address: String nationality: St i ti lit String degree_level: String grade: Integer IQ_kvot: Integer $average_age: Integer

Teacher T h
pnr: Integer teacher_name: String role: String ped_competence: String d t St i admin_competence: String prof_competence: String percentage_of_full_time: Integer salary: Integer martial_state: martial state: String research_engagement: String

Course C
course_number: Integer course_name: String course_description: String p g no_of_students: Integer teacher_name: String equipment_type: String

Book
book_number: Integer ISBN_number: String title: String price: Real

Cc khi nim c bn
Phn tch Thit k HT

Object Class Cl Attribute Operation Relationships Interface (Polymorphism)

37

Xc nh tc v
Phn tch Thit k HT

Person
pnr: Integer name: String birth_date: Integer address: String teaches: Course operate on name() age() address() change_address(new_address)

status

Compartment 1 . p Compartment 2 class properties peer-to-peer relationships Compartment 3

behaviour

Objects manage their own data using their own operations i th i ti

Tc v (Operation)?

CourseOffering
Class
addStudent deleteStudent getStartTime getEndTime

Operation

39

Thng ip (message)
Phn tch Thit k HT

Thng ip l mt php gi tc v ca mt i tng t c th th. Thng ip bao gm 3 phn


i tng ch Du hiu nhn dng ca tc v mun gi Danh h th D h sch thng s gi i

V d:

aCircle.SetRadius(3); aCircle.Draw(pWnd); aCircle Draw(pWnd);

40

Course
course_number: String course_name: String no_of_students: Integer teacher_name: String change-teacher(teacher_name) remove-teacher(Teacher) check_Number of students

Method
Phn tch Thit k HT

A method can change the characteristics of one or several attributes It may create, change, or remove the objects links to other objects It may control some status of the objects attributes

State St t 1 Polish: Course


PPP234 Polish 12 Adamski

State 2 Polish: Course


PPP234 Polish 12 Szczyperski

ID: 434356
Gran Persson: Student 2312302456 Gran Persson 95

Methods are constrained by the value of object attributes and links when they is invoked.

Person
pnr: Integer name: String birth_date: Integer address: String name() age() address() change_address(new_address) g _ ( _ )

Tc v mc th hin
Phn tch Thit k HT

243543948 Pelle
7812233455 Pelle Jansson 781223 Laxgatan 23, 187 88 Hagstra

Uses the method stored in the class object

Changes the data stored in the instance object Pelle.change_address(Karpgatan 25, 345 43 lvsj)

Objects store only data. Classes store methods. When an operation must be performed on an object, a call to the class method is being made.

Operation v method
Phn tch Thit k HT

Class name Object attributes Object operations UML notation


implemented by p y

method . method .. . method .. . ..

Tc v tht s ?
Phn tch Thit k HT

Vi hot ng c m hnh tt hn di dng Lp giao dch pg


Cha cc c trng di dng thuc tnh ca lp Lu gi cc thng tin giao dich (sales over a period of time, e.g. in order to respond to warranty claims, or to audit the shops accounts) )

Nu khng lu gi thng tin v giao dch th c th s dng tc v ca mt lp (khng cn phi a ra lp ring)

Hng dn tm tc v
Phn tch Thit k HT

The most important thing is not to expect to get things right at the first attempt You will always need to revise your assumptions and attempt. models as your understanding grows.

Hnh d H h dung mi lp nh mt actor l c nhim i l h t t c lp hi v lm hay hiu mt iu xc nh no t tc v trong lp cha d liu m n cn cho vic update hay truy cp Ch ti vic cha xc nh y tt c cc thuc tnh

Case Study: xc nh tc v (1)


Phn tch Thit k HT

On the former lecture, we modelled the educational , y g material. So far, we have only designated the classes. Supplement them with relevant attributes and operations. To give you some idea, the educational material may be operated on in the following: - it must be accessed and displayed. Here different data such as ID, ISBN, author, title, keywords, sections and paragraphs may be displayed. - its size must be computed in number of words. - it cost must be available. Please observe that the its t tb il bl Pl b th t th conference articles and internal technical reports do not cost anything.

Case Study: xc nh tc v (2)


Phn tch Thit k HT

- you must assess the readability of the publications. When g , g q y y doing this, the linguistic quality and style must be evaluated. Assume here that there is a special routine that is able to check the spelling, and the style of the teaching material. material Please observe that you dont need to do this for don t books. Their readability has already been checked by the editors. - the international publications are usually scientifically graded on the scale 1-10. The more series publication the higher the grade. When choosing the course literature, one wishes to eliminate the publications having grades lower than 5. To be able to do this, one must access their grades

Cc khi nim c bn
Phn tch Thit k HT

Object Class Cl Attribute Operation Relationships Interface (Polymorphism)

48

Relationship: links
Phn tch Thit k HT

This link expresses a p logical connection between a student and a course

ID: 44000122

ID: 434356

Polish: Course
PPP234 Polski 12 Adamski

Gran Persson: Student


2312302456 Gran Persson 95

A link is a relationship between two objects. objects

Relationship: associations
Phn tch Thit k HT

Course
course_number: String course_name: String g no_of_students: Integer teacher_name: String

Student
pnr: Integer student_name: String g IQ_kvot: Integer

reads

Class level Instance level


ID: 44000122 ID: 434356

Polish: Course
PPP234 Polski 12 Adamski

Gran Persson: Student


2312302456 Gran Persson 95

An association is a relationship between classes.

Cc khi nim c bn
Phn tch Thit k HT

Object Class Cl Attribute Operation Relationships Interface (Polymorphism)

51

Giao din (Interface)?


Phn tch Thit k HT

Giao din hnh thnh a hnh Giao din Gi di h t ki t l tr kin trc plug-and-play d l
Tube <<interface>>

Shape

Pyramid Draw D Move Scale Rotate

Cube

Realization relationship

Interface v a hnh (Polymorphism)?


Phn tch Thit k HT

Kh nng che du nhiu vic thc thi khc nhau di mt giao din (interface) duy nht

Manufacturer A

Manufacturer B

Manufacturer C

OO Principle: Encapsulation
53

Giao din
Tube

Pyramid

Shape

Cube

Tube <<interface>>

Shape p

Draw Move Scale Rotate


54

Pyramid

Cube

Lp tru tng v phng thc tru tng (Abstract Class v Abstract Method)
Phn tch Thit k HT

public abstract class Account { protected int accNo; protected int balance; public Account(int an, int b){ Savings accNo = an; balance = b; } withdraw( ) public int balance(){ return balance; } public abstract void withdraw(int amount);

Account accNo balance balance( ) withdraw( )

Cheque ODLimit ODLi it withdraw( )

55

Chng, tha k, s dng li (Overriding, Inheritance, Reusing)

Phn tch Thit k HT

public class Savings extends Account { public Savings(int an, int b) { super (an, b); }

Account accNo balance balance( ) withdraw( ) Savings Cheque ODLimit ODLi it withdraw( )

public void withdraw(int amount) withdraw( ) { if (balance > amount) balance -= amount; b l t }

56

Chng v bin ca lp (Overriding, Class Variable)


Phn tch Thit k HT

public class Current extends Account { private static int ODlimit=100; p public Current(int an, int b) ( , ) { super (an, b); } public void withdraw(int amount) { if (balance+ODlimit > amount) balance -= amount; = } }

Account accNo balance balance( ) withdraw( ) Savings withdraw( ) Cheque ODLimit ODLi it withdraw( )

57

Thi gian chy v a hnh tha k RunRun-time v inherited polymorphism


import java.io.*; public class withdrawCtrl { public Account getAccount() throws IOException { int d =2; Account A; if (d==1) Savings A= new Savings(100, 1000); else A= new Current(120,2000); Current(120 2000); withdraw( ) return A; }

Phn tch Thit k HT

Account accNo balance balance( ) withdraw( )

Cheque ODLimit ODLi it withdraw( )

public void withdrawCtr() throws IOException { Account A; A=getAccount(); int amount =100; 100; System.out.println (A.balance()); A.withdraw(amount); }
58

2. Biu lp
1. Biu lp ? 2. Biu di 2 Bi din quan h ( l ti (relationship) hi )

59

Biu lp v i tng
Phn tch Thit k HT

60

Class v Object
Phn tch Thit k HT

Account
Class variable balance(?) withdraw(X)
SamAcc:: aNo=101 balance=500 soFar=100

Name of Class Data Declaration Methods Definition

aNo balance dayLimit = 200 soFar balance( ) withdraw( ) --instances

SamAcc::Accoun t aNo = 101 balance = 500 soFar=100

Name of Object Data Values

MicAcc::Accoun t aNo = 105 balance = 600 soFar 200 soFar=200

Name of Object Data Values

61

Lp v i tng
Phn tch Thit k HT

Mt i tng biu din cho mt thc th c th l thc th vt l khi nim hay l phn mm l, mm Mt i tng l mt khi nim, s tru tng hay mt vt m c ranh gii r rng, v c ngha r rt cho mt ng dng Mt lp l mt m t cho mt nhm cc i tng c chung thuc tnh, ng x, mi quan h v ng ngha (semantic). Lp l mt khun mu to ra i tng Mi i tng trong mt h thng u c ba c tnh: trng thi, ng x v danh nh.
62

Trng thi (state)


Phn tch Thit k HT

Trng thi ca mt i tng l mt trong nhng tnh t t h trng m i tng c th t t i trong mi t tn ti t i trng. Trng T ng thi ca mt i tng thng s thay i th theo thi gian, trng thi ca i tng thng c c gn vi thi im im. Trng thi ca mt i tng c xc nh qua mt tp cc thuc tnh, v mi quan h vi cc i tng khc.

63

Hnh vi (Behaviour) v Danh nh (Identity)


Phn tch Thit k HT

Hnh vi xc nh mt hot ng ca mt i tng (thay t (th i trng thi theo thi gian) nhm t th i ) h p ng cc yu cu t cc i tng khc, n tiu biu cho nhng g m i tng ny c th lm Danh nh dng phn bit gia cc i tng ngay c khi n c cng trng thi v gi tr cc thuc tnh

64

Tnh kh kin
Phn tch Thit k HT

Nu thuc tnh c tnh kh kin l cng cng (public +), th n c th c nhn thy v s dng ngoi lp Nu thuc tnh c tnh kh kin l ring (private -), bn s khng th truy cp n t bn ngoi lp Nu thuc tnh c tnh kh kin l bo v (protected #) th cng ging nh thuc tnh c tnh kh kin l ring nhng l cng cng i vi cc lp con

65

Biu lp (class diagram)


Phn tch Thit k HT

c lp vi ngn ng Nhng k hiu cho php c t lp, d liu hay thuc tnh ca chng (private) v phng thc (method), tha k (method) s th k Nhng s a ra nhng hnh nh v quan h cu trc v nhng ng x v chc nng ca cc lp

66

Mc ch ca biu lp
Phn tch Thit k HT

Lm ti liu cho cc lp cu thnh h thng v h thng th con M t kt hp, tng qut ha v cc quan h kt tp gia cc lp trong biu gi t ong bi Ch r c trng ca lp, cc thuc tnh v tc v chnh ca mi lp Biu lp c dng khp ni trong chu trnh pht trin, t bi ton n m hnh ci t trin

67

Cc lp d tuyn (*)
Phn tch Thit k HT

68

Ni dung
Biu din Lp v i tng Biu di Bi din quan h (relationship) ( l ti hi )

69

Quan h (relationship)
Phn tch Thit k HT

Kt hp (Association) Kt tp (aggregation) Kt cu (Composition) Ph thuc (Dependency) Chuyn bit v tng qut ha (Specialization/Generalization)

70

Kt hp (Association)
Phn tch Thit k HT

Association Name Professor University

Works for Role Names

Class

Professor Employee Employer

University

71

Nhng rng buc ca kt hp


Phn tch Thit k HT

Mt kt hp phi c mt tn t bn trn hay k vi ng lin h i li Tn ca kt hp phi phn nh ni dung, l cm ng t, tn c th b q bit khi tn vai tr t qua c it ca n c dng, trnh dng tn khng cng thm thng tin Mi u ca kt hp l mt vai tr (role) ch ra vai tr ca lp trong kt hp, tn vai tr phi l duy nht ng vi mt lp, tn vai tr phi l mt danh t t cui ng kt hp Chn mt trong hai: tn kt hp hay tn vai tr
72

Vai tr
Phn tch Thit k HT

Course plays two roles: taught-by managed-by

Course C
course_number: String course_name: String no_of_students: no of students: Integer teacher_name: String

teaches t h

taught-by t ht b

Lecturer L t
pnr: Integer student_name: String IQ kvot: Integer Q_ g

teaches

is_in_charge_of managed_by

manages

One class may have many roles. roles

Kt hp qui
Phn tch Thit k HT

Tn vai tr l bt buc

74

teaches

Association degree
Student
Phn tch Thit k HT

pnr: Integer student_name: String IQ_kvot: Integer

A unary association

Course
course_number: String course_name: String no_of_students: Integer teacher_name: String

A binary association

Student
pnr: Integer student_name: String IQ_kvot: Integer

reads

An association may be unary binary or ternary unary, binary,

Bn s (Multiplicity)
Phn tch Thit k HT

Xc nh bao nhiu i tng tham gia kt hp

Many M One or more

76

Lp kt hp (Association class)
Phn tch Thit k HT

account

1..*

0..*

card

UsedFor
dateIncluded

Associatio n class

student

0..* No Name
grade

1..*

course

77

Kt tp (aggregation)
Phn tch Thit k HT

Kt tp l quan h gia ton b v b phn


Mt i tng to t nhng i tng kh c t c t h t khc tnh vt l Mt i tng l tp hp ca nhng i tng khc c tnh logic Mt i tng cha nhng i tng khc c tnh vt l
Whole Student
Aggregation
78

Part Schedule

Case study: Xc nh lp kt hp (1)


Phn tch Thit k HT

Students at SU may read many different courses. The , students however, should not read more than five courses during one semester. A course may be given on several occasions per semester. For each occasion, different teachers may be involved on the course This course. implies that these teachers may choose different course literature. The choice of the book does not only depend on th t the teacher, b t also on the students average IQ h but l th t d t value. A course may only start if there are at least 15 students reading this course. Otherwise, the course must be cancelled. Teaching for less than 15 students would be too expensive expensive.

Case study: Xc nh lp kt hp (2)


Phn tch Thit k HT

The courses are taught by lecturers. The fact that you are a lecturer does not hinder you from reading courses at university. There may be cases that a lecturer reads and teaches on one and the same course simultaneously. sim ltaneo sl This is in cases when the lect e is a hen lecturer PhD student. The work he has put into developing and teaching on a course gives him credit point within his PhD studies.

Student
pnr: Integer student_name: String $average_IQ: String 1..1 reads 1..5 1..5

0..*

Teacher
pnr: Integer lecturer_name: String ...

Phn tch Thit k HT

reads taught_by

Course Occassion
1..* uses_book 15..* 1..* offered_by reads start_date: Date finish_date: Date Course Occassion corresponds to the association class in an association of degree 4. 4

Book
book_number: Integer ISBN_number: String title: String price: Real 1..1

Course
course_number: Integer course_name: String course_description: course description: String

Composition (kt cu)


Phn tch Thit k HT

Kt cu l mt dng ca kt tp, thi gian sng ca i tng b phn khng vt qu thi gian sng ca i tng ton b Khi ton b b xa th b phn cng b xa B phn c th b xa trc khi ton b b xa
Whole Student St d t Part Schedule S h d l

Aggregation

82

Aggregation v composition
Phn tch Thit k HT

83

Chiu (Navigation) (Navigation)


Phn tch Thit k HT

84

Ph thuc (Dependency)
Phn tch Thit k HT

Mt bin i trn mt thnh phn s gy ra s bin i trong thnh phn khc

Class

Client

Supplier

Componen t
Supplier

Package

Dependency relationship

Client

ClientPackage

SupplierPackage

Dependency relationship
85

Specialization/Generalization
Phn tch Thit k HT

Chuyn bit ha(/tng qut ha): l qu trnh tinh ch mt lp thnh nhng lp chuyn bit hn hn. Chuyn bit ha b sung thm chi tit v c t cho lp kt qu. Lp mang tnh khi qut c gi l l cha ( lp h (superclass), k qu chuyn bi h l ) kt h bit ha l vic to ra cc lp con (Subclass). Tng qut ha v chuyn bit lin quan ti Tha k (Inheritance)
Lp con tha k attributes, operations, v relationships p p p Lp con c th: Cng thm attributes, operations, relationships Xc nh li tc v c tha k (ca tion!) (caution!)
86

Generalisation/specialisation
Phn tch Thit k HT

Person

Often we find similar properties or terms in the Universe of Discourse, which however, are not , , exactly the same Teacher

Student Class Object

Anna Bok

Ulla Rask

Sven Lund Erik Gadd Olle Macho

Generalisation/specialisation
Phn tch Thit k HT

Person

Student Class Object

Teacher

Anna Bok Ulla Rask Erik Gadd Olle Macho Sven Lund

Existence dependency Hand


Phn tch Thit k HT

is_part_of

* Finger

has

Transitivity
object A contains object B, and object B contains object C, then A contains C.

is_part_of

* Nail

has

Asymmetry A t
if A contains B, then B cannot contain A. A

Pht trin phn cp lp


Phn tch Thit k HT

90

Pht trin phn cp lp


Phn tch Thit k HT

91

Tha k
Phn tch Thit k HT

Abstraction
Employee

Person Customer Supplier hourly y paid

More general (superclasses) Subclasses are fully Consistent with super classes and add more information More specialized (subclasses) ( b l )

monthly paid

weekly y paid

Driver

Cleaner

Real-world entities on R l ld titi leaves

Sales assistant

Tha k (Inheritance) v tng qut ha


Phn tch Thit k HT

93

Tha k n
Phn tch Thit k HT

Ancestor
Account balance name number Withdraw() CreateStatement()

Superclass (parent)

Generalizatio n Relationship

Checking

Savings GetInterest() Withdraw()

Subclasses

Withdraw()

Descendents
94

a tha k
Phn tch Thit k HT

FlyingThing
multiple inheritance

Animal

Airplane

Helicopter

Bird

Wolf

Horse

Use multiple inheritance only when needed, and always with caution !
95

V d

GroundVehicle G dV hi l

Superclas s (parent)

weight licenseNumber register( )

owner 0..* 1

Person

generalization

Subclass

Car size

Truck tonnage getTax( )

Trailer

96

Lp tru tng
Phn tch Thit k HT

Person (abstract)
pnr: Integer name: String birth_date: Integer address: String

Abstract classes create a hi h highlevel modelling vocabulary. vocabulary


Teacher

Student
IQ-value: Integer student_points: Integer t d t i t I t

Ped_skill: Integer experience: Integer i I t

Rng buc
Phn tch Thit k HT

Cho php cng thm ng ngha mi Rng b R buc l mt St i ng trong ngoc nhn t String t h t gn thnh phn m n p dng Dng D quan h ph thuc nu c nhiu thnh phn h th hi th h h m rng buc p dng
Professor Member {Subset}
Deparment Head

Department

98

Phn loi trong K tha


Phn tch Thit k HT

4 loi (rng buc) Disjoint Overlapping Complete Incomplete

99

Tha k v tng qut ha


Phn tch Thit k HT

100

Phn loi
Phn tch Thit k HT

Disjoint? j
Membe r Staff Student

Overlapping pp g ? Internal

Student Local

Discriminator
Student mode Internationa l Local PGrad s type UGrad s

Complete?
Student Asian sa Local oca

LocalPGrad L lPG d s

Xc nh aggregation
Phn tch Thit k HT

Sometimes, the teachers cannot utilise the whole b k during th i courses, only parts h l books d i their l t of it. This is because for some courses it may be difficult to find an optimal book. Not every p y teacher has time to write specifically tailored own material. Hence, the teaching material consists of different book chapters or even book sections. Due to the fact that the material conveyed in these books may quickly age (t i l within computer science), th (typical ithi t i ) the constellation of the teaching material often g changes.

Book

0..*

Phn tch Thit k HT

1..1

is_part_of 0..*

1..*

has 0..* 1..*

Chapter

Course Literature

1..1 1.. 1 *

is_part_of 0..* has 0..*

Section

Study case: generalisation/specialisation (1)


Phn tch Thit k HT

The teaching material does not only consist of books. books Teaching material can be anything: - books, or parts of books as has already been modelled. - national publications, such as technical reports and working articles articles. - different kinds of international publications such as journal-, conference- or workshop papers.

Study case: generalisation/specialisation (2)


Phn tch Thit k HT

SU wishes to record this information so that one can clearly see the constellations of teaching material. Irrespective of whether it was internationally published or not, whether it was a book or report, and whether some of this teaching material was written by the teachers involved on the course. SU also wishes to know all the roles involved in teaching. They are course leaders, course executors, advisors, assistants. I addition, we have varying groups of students. i t t In dditi h i f t d t We have Swedish and foreign exchange students. Regarding , y y g y the Swedish students, they need not be necessarily originally Swedish. The prerequisite for being classified as a Swedish student is that the student lives permanently in Sweden.

Study case: biu


Phn tch Thit k HT

Course Literature

Book

0..*

Publication

1..1 is_part_of 1..* has Chapter 0..* 1..* 0..* Book Literature National Publication International Publication

1..1 is_part_of 0..* 1.. has 1 *h Section 0..* Technical Report Working Paper Conference Article Journal Article Worksho p Article

Biu
Phn tch Thit k HT

Course Literature

Educational Material

0..*

0..*

Book

0..*

0..*

Publication

1..1 is_part_of 1 1 is part of 0..* 1..* has Chapter 0..* 1..* 0..* National Publication International Publication

Book Literature

1..1 is_part_of 1..* has Section 0..*

0..*

Technical Report

Working Paper

Conference Article

Journal Article

Workshop Article

Biu lp Person
Phn tch Thit k HT

SU also wishes to know all the roles involved in teaching. They are course leaders, course executors, advisors, course developers, assistants. In addition, we have varying group of students. Student

Person

Teaching T hi Staff

Swedish Student

Foreign Student

Course leader

Course Executor

Advisor

Assistant

Native Swedish Student

Non-native Swedish Student

Bi tp
Phn tch Thit k HT

Books and journals The library contains books and journals. It may have several copies of a given book. Some of the books are for short term loans only. All other books may be borrowed by any library member for three weeks. Members of the library can normally borrow up to six items at a time, but y p , members of staff may borrow up to 12 items at one time. Only members of staff may borrow journals. journals Borrowing The system must keep track of when books and journals are borrowed and returned, enforcing the rules described above.
109

Phn tch Thit k HT

UML/NN 110

Phn tch Thit k HT

UML/NN 111

Biu lp qun l thu xe


Phn tch Thit k HT

VD
Phn tch Thit k HT

UML/NN 113

Cu hi
Phn tch Thit k HT

Gii thch mt s khi nim v hng i tng? Khc bit gia lp v i tng ? Lp dn xut ? Lp k tha nhng g ? Quan h ca lp ? Cc loi quan h ? Rng buc gia cc quan h ? g Phn loi trong k tha?

114

Thc hnh
Phn tch Thit k HT

Pht hin thc th v cc tng tc ca cc h thng th


H H H H H H H H thng thng th thng thng th thng thng thng thng Thay th ti x Kho th Kh Qun l kho Safe H S f Home Th vin trc tuyn ATM u gi Tnh cng X nghip may may
115

You might also like