CHƯƠNG IV Biểu đồ llớp - · PDF filePhân tích ThiếtkếHĐT 1....
Transcript of CHƯƠNG IV Biểu đồ llớp - · PDF filePhân tích ThiếtkếHĐT 1....
CHƯƠNG IVCHƯƠNG IVBiểu đồ lớpBiểu đồ lớpBiểu đồ lớpBiểu đồ lớp
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
UMLUML
1
Nội dungNội dung
1. Phương pháp hướng đối tượng1 Phươ há hướ đối tượ ?1. Phương pháp hướng đối tượng?2. Xác định đối tượng
2 Biể đồ lớ2. Biểu đồ lớp1. Biểu đồ lớp?2 Biể diễ hệ ( l ti hi )2. Biểu diễn quan hệ (relationship)
2
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
1. Phương pháp hướng đối tượng1. Phương pháp hướng đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Accountithd
amountamount message
StructuredStructured
aNo balance
Account
withdrawmessagewithdrawal
message
ER DFD with Data Store Structure Chart
:MyAccountwithdraw(X)
MyAccount
aNo= 101Objects
OO approachOO approach
:MyAccount( )balance=500
balance( )withdraw( )
Objects
3
withdraw( )- - -
Nguyên lý cơ bảnNguyên lý cơ bản
Obj t O i t tiObject Orientation
tion
on yty
apsu
lat
bstra
ctio
ierar
chy
odul
arit
EncAb HMo
4
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Những thuộc tính cơ bảnNhững thuộc tính cơ bảnPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Data and operations
EncapsulationEncapsulation
Classes and objects
Generalisation/Specialisation
Polymorfism + y
Object-orientation (OO)
+=
Sự trừu tượng (Abstraction)?Sự trừu tượng (Abstraction)?
Salesperson
Not saying Whichsalesperson –just a jsalesperson in general!!!
ProductCustomer Product
M C l it6
Manages Complexity
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tính đóng gói (Encapsulation)?Tính đóng gói (Encapsulation)?Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Che dấu việc thực thi (tính mềm dẻo)Clients depend on interface
How does an object encapsulate?
I R ili
What does it encapsulate?
7
Improves Resiliency
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tính đóng góiTính đóng góiPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
easy to use (dễ dùng)
-3 advantages ? )easy to use (dễ dùng)
less coupling (liên kết thấp)
more reliable (tin cậy)
balance(?)
Account
aNo
Name of Class
DataMy Account::aNo=101balance=300
balance(?)
withdraw(X)balancebalance( )withdraw( )
Data(usually hidden)
Methods(usually
- - -(usually interface)
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Giao tiếp qua interface (giao diện)Giao tiếp qua interface (giao diện)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Manufacturer AManufacturer B Manufacturer C
Polymorfism
9
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tính phân đoạn (Modularity)?Tính phân đoạn (Modularity)?Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
OrderEntry
Order Processing System OrderSystem
Fulfilment (thực hiện)
Billing
10
Manages Complexity
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Hệ thống cấp bậc (Hierarchy)? Hệ thống cấp bậc (Hierarchy)? Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Increasing abstraction
Asset
abstraction
RealEstateBankAccount Security
Savings Checking Stock Bond
Decreasing b t ti
Savings Checking Stock Bond
Những thành phần cùng mức phân cấp sẽ
11
abstraction Những thành phần cùng mức phân cấp sẽ cùng mức trừu tượng
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Xác định đối tượngXác định đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
ObjectClClassAttributeOperationRelationshipsInterface (Polymorphism)
12
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Đối tượngĐối tượng (Object)(Object)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
W d fi bj t t b t ti
Rumbaugh et al. (1991)
We define an object as a concept, abstraction, or thing with crisp boundaries and meaning for the problem at hand. Objects serve twothe problem at hand. Objects serve two purposes:
they promote understanding of the real worldthey 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. Not every modeller may agree on the choice, meaning, and sometimes the need for tangible and intangible objects.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Đối tượng ?Đối tượng ?Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thực thể vật lýểThực thể khái niệm
Thực thể phần mềm…Chemical Process
Truck
Linked List
14
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Đối tượngĐối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Một đối tượng là một khái niệm, một sự trừu tượ h là ột ự ật (thi ) ó h iới õtượng hay là một sự vật (thing) có ranh giới rõ ràng và có ý nghĩa cho một ứng dụng Một đối tượng óMột đối tượng có
Trạng thái (State)Hành vi (Behavior)Hành vi (Behavior)Định danh (Identity)
15
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
ObjectObjectPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Relationaldatabases
Sven Lund
Olle Macho
Datamodelling
FeelingsOlle Macho
Ulla Rask
Anna LindProject
management
Erik Gadd
StudentsCourses
A thing can be either concrete or
A thing can be either concrete or
An object is an instance of a thingAn object is an instance of a thing
Courses
An object is something weAn object is something we
abstract.abstract.
instance of a thing. instance of a thing. An object is something, we want to hold information about.
An object is something, we want to hold information about.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Biểu diễn đối tượngBiểu diễn đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
: Professora + b = 10
ProfessorClarkClass Name Only
Professor ClarkProfessorClark :
Professor Object Name Only
Class and Object Name
17
Class and Object Name
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Ví dụ một đối tượngVí dụ một đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Coffee Cl
Bl k ff
Coffeemachine Class
Coffee machineAttributes• Black coffee
• Coffee with sugar
• Coffee with cream
Attributes...
Operationscream• Coffee with
cream and sugar
OperationsBlack coffeeCoffee with sugargCoffee with creamCoffee with cream
and sugarand sugar...
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Study case: Xác định đối tượng (1)Study case: Xác định đối tượng (1)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
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 Stockholmworks for Ericsson Radio System. Jane is a lecturer and works at Stockholm 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 ghas 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 b li th t th k l d f P li h ill b t ti ll i b ibelieve that the knowledge of Polish will substantially improve business 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 PolishTwo 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 S di h d P t ld t l t it t P li hSwedish, and Peter would translate it to Polish.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Study case: Xác định đối tượng (2)Study case: Xác định đối tượng (2)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
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 John’s 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 P li h hi h “Th k ”Polish, which means “Thank you”. Later that evening, John comes home, gets Peter’s translation and pays him money. He also reads the letter, and things that P t h d d f l j b H h l t P tPeter has done a wonderful job. Hence, he complements Peter on his professionalism.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Xác định đối tượngXác định đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
ObjectClClassAttributeOperationRelationshipsInterface (Polymorphism)
21
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Lớp (Class)?Lớp (Class)?Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Một lớp là mô tả của một nhóm đối tượng với th ộ tí h ( ti tt ib t ) h hà h ithuộc tính (properties - attributes) chung, hành vi (behavior - operations), quan hệ (relationships), và ngữ nghĩa (semantics)và ngữ nghĩa (semantics)
Một đối tượng là một thể hiện (instance) của một lớplớp
Một lớp là một sự trừu tượng trong đó nó:Nhấn mạnh đến những đặc tính chungNhấn mạnh đến những đặc tính chungBỏ qua những đặc tính riêng biệt
22
OO Principle: Abstraction
Lớp khóa họcLớp khóa học
ClassCourse
PropertiesName
BehaviorAdd a student
a + b = 10LocationDays offeredCredit hours
Start time
Delete a studentGet course roster
Determine if it is fullStart timeEnd time
23
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Biểu diễn lớpBiểu diễn lớpPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Professora + b = 10
Professor Clark
ProfessornameempID
Class Name
Attributes (tc) empID
create( )save( )delete( )
Operations (hv)
24
delete( )change( )
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Study case: Xác định lớp (1)Study case: Xác định lớp (1)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
We need write an application supporting us in managing the information about university operation Right now atthe information about university operation. Right now, at Stockholm University we have a substantial amount of students - 35 000 students. To manually manage all info mation abo t st dents is simpl impossible Hence SUinformation 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 andThey want to provide better service to their students, and 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.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Study case: Xác định lớp (2)Study case: Xác định lớp (2)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
This gives them better insight into the education on the course level and provides a solid basis for evaluating thecourse level, and provides a solid basis for evaluating the 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 haveTo be able to provide high quality education, SU must have highly competent lecturers. SU wishes to store information about their lecturers and their state of competence and its d l tdevelopment.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
SC: Biểu đồ lớpSC: Biểu đồ lớpPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Student Lecturer Book shop
B kCourse
CourseEvaluation
CompetenceEvaluation
BookLibrary
CourseO l i
CompetenceOverlapping
University Do we need a class called University?
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Xác định đối tượngXác định đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
ObjectClClassAttributeOperationRelationshipsInterface (Polymorphism)
28
Thuộc tính (Attribute) ?Thuộc tính (Attribute) ?
Class Object
:CourseOfferingb 101
Attribute Attribute Value
number = 101startTime = 900endTime = 1100CourseOffering
number
:CourseOfferingnumber = 104
numberstartTime endTime
number 104startTime = 1300endTime = 1500
29
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thuộc tính và trạng tháiThuộc tính và trạng tháiPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Course
course_number: Stringcourse name: Stringcourse_name: Stringno_of_students: Integerteacher_name: String
Polish: CourseState 1
Polish: CourseState 2
Polish: CourseState 3
Polish: CoursePPP234Polish12Adamski
Polish: CoursePPP234Polish34Szczyperski
Polish: CoursePPP234Polish34
Adamski Szczyperski
When an attribute value changes, the object itselfWhen an attribute value changes, the object itself changes states.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTTìm thuộc tínhTìm thuộc tính
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Đối tượng được mô tả tổn quát như thế nào ?ợ g ợ qPhần nào trong mô tả tổng quát có thể áp dụng cho lãnh vực quan tâm ?Mô tả tối giản cần thiết cho ứng dụng sẽ như thế nào ?
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Che dấu thông tinChe dấu thông tinPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
name()Class: Person
Class: Studentname()
age()address() Change_address (Tjädervägen ….)
pnr: Integername: String David Parnas
– the founder
change address(new address)
changesdata
(Tjädervägen ….)birth_date: Integeraddress: String
the founder of OO
change_address(new_address)
Class: Studentrequiresservice
Only the object’s own code may read and change its own d t l
Only the object’s own code may read and change its own d t l
Change_address (Tjädervägen ….)
data values.data values.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tính khả kiếnTính khả kiếnPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Person
pnr: Integer
In UML, the visibility is normally designated by a plus or minus symbol:
- pnr: Integer- name: String- birth_date: Integer- address: String
+ for public visibility- for private visibility
g
+ name()+ age()- count age()+ dd () Not only the attributes are hidden+ address()+ change_address(new_address)
Not only the attributes are hidden. Operations may be hidden as well.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Case Case Study: Study: xác định thuộc tính (1)xác định thuộc tính (1)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
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 onemore mnemotechnic identifier to be managed by people. Hence, one 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 SURecent studies have shown that there are too many old students at 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 gives some results, the p g g ,Swedish politicians require that SU regularly compiles the average age of the students.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Case Case Study: Study: xác định thuộc tính (2)xác định thuộc tính (2)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Concerning the lecturers, SU needs to store the basic personal data such as name, address, the job role (lecturer, advisor, course developer) and also qualifications (pedagogical administrative anddeveloper), and also qualifications (pedagogical, administrative, and 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/hehow 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 coursewith 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 yespecially 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 gtitle. We must also know their price and on which course they are being utilised.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Case Case Study: Study: thuộc tínhthuộc tínhPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
St d t T h CStudentpnr: Integerstudent_name: Stringaddress: String
ti lit St i
Teacherpnr: Integerteacher_name: Stringrole: String
d t St i
Course
course_number: Integercourse_name: Stringcourse description: Stringnationality: String
degree_level: Stringgrade: IntegerIQ_kvot: Integer$average_age: Integer
ped_competence: Stringadmin_competence: Stringprof_competence: Stringpercentage_of_full_time: Integersalary: Integermartial state: String
_ p gno_of_students: Integerteacher_name: Stringequipment_type: String
martial_state: Stringresearch_engagement: String
BookBook
book_number: IntegerISBN_number: Stringtitle: Stringprice: Realprice: Real
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Các khái niệm cơ bảnCác khái niệm cơ bảnPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
ObjectClClassAttributeOperationRelationshipsInterface (Polymorphism)
37
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Xác định tác vụXác định tác vụPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Person
pnr: Integername: String status Compartment 1 . name: Stringbirth_date: Integeraddress: Stringteaches: Coursename() operate on
status pCompartment 2 • class properties• peer-to-peer relationshipsCompartment 3
age()address()change_address(new_address)
behaviour
Objects manage their own data i th i tiusing their own operations
Tác vụ (Operation)?Tác vụ (Operation)?
CourseOffering
addStudentClass
addStudent deleteStudentgetStartTimegetEndTimeOperation
39
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thông điệp (message)Thông điệp (message)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thông điệp là một phép gọi tác vụ của một đối tượ thểtượng cụ thể.Thông điệp bao gồm 3 phần
ố íĐối tượng đíchDấu hiệu nhận dạng của tác vụ muốn gọiD h á h thô ố iDanh sách thông số gọi
Ví dụ: aCircle.SetRadius(3);aCircle Draw(pWnd);aCircle.Draw(pWnd);
40
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
MethodMethodCoursePhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
course_number: Stringcourse_name: Stringno_of_students: Integerteacher_name: String A method can change the characteristics
of one or several attributeschange-teacher(teacher_name)
remove-teacher(Teacher)check_Number of students
of one or several attributesIt may create, change, or remove the object’s links to other objects
St t 1
It may control some status of the object’s attributes
Polish: CoursePPP234Polish
State 1
State 2 ID: 434356Polish12Adamski
Polish: CoursePPP234Polish12
Göran Persson: Student
2312302456Göran Persson9512
Szczyperski95
Methods are constrained by the value of object attributes and links when they is invoked.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tác vụ ở mức thể hiệnTác vụ ở mức thể hiệnPersonPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
pnr: Integername: Stringbirth_date: Integeraddress: String
Pelle
7812233455
243543948name()age()address()change_address(new_address)
Pelle Jansson781223Laxgatan 23, 187 88 Hagsätra
g _ ( _ )
Uses the method stored in the class object
Pelle.change_address(Karpgatan 25, 345 43 Älvsjö)
Changes the data stored in the instance object
Objects store only data. Classes store methods.When an operation must be performed on an object, aWhen an operation must be performed on an object, a call to the class method is being made.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Operation và methodOperation và methodPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Class name
Object attributes
Object operations …………….
method
implemented by
UML notation
Object operations …………….……………..…………………………….
……………..
method
method
p y
…………………………….……………..………………
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tác vụ thật sự ?Tác vụ thật sự ?Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Vài hoạt động được mô hình tốt hơn dưới dạngLớp giao dịchp g ị• Chứa các đặc trưng dưới dạng thuộc tính của
lớp• Lưu giữ các thông tin giao dich (sales over a• Lưu giữ các thông tin giao dich (sales over a
period of time, e.g. in order to respond to warranty claims, or to audit the shop’s accounts))
Nếu không lưu giữ thông tin về giao dịch thì có thể sử dụng tác vụ của một lớp (không cần phải đưa ra lớp riêng)đưa ra lớp riêng)
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Hướng dẫn tìm tác vụHướng dẫn tìm tác vụPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
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
Hì h d ỗi lớ h ột t độ lậ ó hiệ
first attempt. You will always need to revise your assumptions and models as your understanding grows.
Hình dung mỗi lớp như một actor độc lập có nhiệm vụ làm hay hiểu một điều xác định nào đó Đặt tác vụ trong lớp chứa dữ liệu mà nó cần choĐặt tác vụ trong lớp chứa dữ liệu mà nó cần cho việc update hay truy cập Chú ý tới việc chưa xác định đầy đủ tất cả các thuộcChú ý tới việc chưa xác định đầy đủ tất cả các thuộc tính
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Case Study: xác định tác vụ (1)Case Study: xác định tác vụ (1)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
On the former lecture, we modelled the educational material. So far, we have only designated the classes. , y gSupplement them with relevant attributes and operations. To give you some idea, the educational material may be operated on in the following: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 t t b il bl Pl b th t th- its cost must be available. Please observe that the conference articles and internal technical reports do not cost anything.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Case Study: xác định tác vụ (2)Case Study: xác định tác vụ (2)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
- you must assess the readability of the publications. When doing this, the linguistic quality and style must be g , g q y yevaluated. Assume here that there is a special routine that is able to check the spelling, and the style of the teaching material Please observe that you don’t need to do this formaterial. Please observe that you don t need to do this for 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, onehigher 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
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Các khái niệm cơ bảnCác khái niệm cơ bảnPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
ObjectClClassAttributeOperationRelationshipsInterface (Polymorphism)
48
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTRelationship: linksRelationship: links
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
´This link expresses a
ID: 44000122 ID: 434356
plogical connection between a student
and a course
Polish: CoursePPP234Polski
Göran Persson: Student2312302456Göran Persson
12Adamski
95
A link is a relationship between two objectsA link is a relationship between two objects.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Relationship: associationsRelationship: associationsPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Course
course_number: Stringcourse name: String
Student
pnr: Integerstudent name: String_ g
no_of_students: Integerteacher_name: String
_ gIQ_kvot: Integer
reads
ID: 44000122 ID: 434356
Class level
Instance level
Polish: CoursePPP234Polski
Göran Persson: Student2312302456Göran Persson
ID: 434356
12Adamski
Göran Persson95
An association is a relationship between classes.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Các khái niệm cơ bảnCác khái niệm cơ bảnPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
ObjectClClassAttributeOperationRelationshipsInterface (Polymorphism)
51
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Giao diện (Interface)?Giao diện (Interface)?Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Giao diện hình thành đa hìnhGi diệ hỗ t ợ kiế t ú “ l d l ”
Tube
Giao diện hỗ trợ kiến trúc “plug-and-play”
PyramidShape
D
<<interface>>
Cube
DrawMoveScaleRotateRotate
Realization relationship
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Interface và Đa hình (Polymorphism)?Interface và Đa hình (Polymorphism)?Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Khả năng che dấu nhiều việc thực thi khác nhau dưới một giao diện (interface) duy nhấtgiao diện (interface) duy nhất
Manufacturer AManufacturer B Manufacturer C
OO Principle:Encapsulation
53
Giao diệnGiao diện
Tube
Pyramid
CubeShape
Tube
Shape<<interface>>
Pyramidp
DrawMoveScale
54Cube
ScaleRotate
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Lớp trừu tượng và phương thức trừu tượng Lớp trừu tượng và phương thức trừu tượng (Abstract Class và Abstract Method)(Abstract Class và Abstract Method)
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
public abstract class Account{
AccountaccNobalance{
protected int accNo;protected int balance;
balancebalance( )withdraw( )
public Account(int an, int b){accNo = an;balance = b;
Savings
ChequeODLi it}
public int balance(){return balance;
}
withdraw( )ODLimit
withdraw( )} public abstract void withdraw(int amount);
}
55
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Chồng, thừa kế, sử dụng lạiChồng, thừa kế, sử dụng lại(Overriding, Inheritance, Reusing)(Overriding, Inheritance, Reusing)
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
public class Savings extends Account
AccountaccNobalancepublic class Savings extends Account
{public Savings(int an, int b){
balancebalance( )withdraw( )
{super (an, b);
}Savings
ChequeODLi itpublic void withdraw(int amount)
{if (balance > amount)
b l t
withdraw( )ODLimit
withdraw( )balance -= amount;
}}
56
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Chồng và biến của lớpChồng và biến của lớp(Overriding, Class Variable)(Overriding, Class Variable)
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
public class Current extends Account
AccountaccNobalancepublic class Current extends Account
{private static int ODlimit=100;public Current(int an, int b)
balancebalance( )withdraw( )
p ( , ){
super (an, b);}
Savings
ChequeODLi itpublic void withdraw(int amount)
{if (balance+ODlimit > amount)
balance = amount;
withdraw( )ODLimit
withdraw( )balance -= amount;
}}
57
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thời gian chạy và đa hình thừa kếThời gian chạy và đa hình thừa kếRunRun--time và inherited polymorphismtime và inherited polymorphism
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
import java.io.*;public class withdrawCtrl{
AccountaccNobalance{
public Account getAccount() throws IOException {int d =2;Account A;
balancebalance( )withdraw( )
if (d==1) A= new Savings(100, 1000);
elseA= new Current(120 2000);
Savings
ChequeODLi itA= new Current(120,2000);
return A; }
withdraw( )ODLimit
withdraw( )public void withdrawCtr() throws IOException {
Account A;A=getAccount(); int amount =100;
58
int amount 100;A.withdraw(amount);
}}
System.out.println (A.balance());
2. Biểu đồ lớp2. Biểu đồ lớp
1. Biểu đồ lớp ?2 Biể diễ hệ ( l ti hi )2. Biểu diễn quan hệ (relationship)
59
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Biểu đồ lớp và đối tượngBiểu đồ lớp và đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
60
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Class và ObjectClass và ObjectPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Account
aNo
Name of ClassClass
variable aNobalancedayLimit = 200soFar
Data Declaration
variable
SamAcc::balance(?)
balance( )withdraw( )- - -
Methods Definition
SamAcc::aNo=101balance=500soFar=100
withdraw(X)
SamAcc::Account
Name of Object MicAcc::Accoun Name of
instances
taNo = 101balance = 500soFar=100
Object
Data Values
taNo = 105balance = 600soFar=200
Object
Data Values
61
soFar 200 Data Values
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Lớp và đối tượngLớp và đối tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Một đối tượng biểu diễn cho một thực thể có thể là thực thể vật lý khái niệm hay là phần mềmlà thực thể vật lý, khái niệm hay là phần mềm…Một đối tượng là một khái niệm, sự trừu tượng hay một vật mà có ranh giới rõ ràng, và có nghĩahay một vật mà có ranh giới rõ ràng, và có nghĩa rõ rệt cho một ứng dụngMột lớp là một mô tả cho một nhóm các đối tượngMột lớp là một mô tả cho một nhóm các đối tượng có chung thuộc tính, ứng xử, mối quan hệ và ngữ nghĩa (semantic).Lớp là một khuôn mẫu để tạo ra đối tượngMỗi đối tượng trong một hệ thống đều có ba đặc
62
tính: trạng thái, ứng xử và danh định.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Trạng thái (state)Trạng thái (state)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Trạng thái của một đối tượng là một trong những tì h t à đối tượ ó thể tồ t i t ôitình trạng mà đối tượng có thể tồn tại trong môi trường. T ng thái ủ một đối tượng thường ẽ th đổiTrạng thái của một đối tượng thường sẽ thay đổi theo thời gian, trạng thái của đối tượng thường được được gắn với thời điểmđược được gắn với thời điểm. Trạng thái của một đối tượng được xác định qua một tập các thuộc tính, và mối quan hệ với cácmột tập các thuộc tính, và mối quan hệ với các đối tượng khác.
63
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Hành vi (Behaviour) và Danh định (Identity) Hành vi (Behaviour) và Danh định (Identity) Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Hành vi xác định một hoạt động của một đối tượ (th đổi t thái th thời i ) hằtượng (thay đổi trạng thái theo thời gian) nhằm đáp ứng các yêu cầu từ các đối tượng khác, nó tiêu biểu cho những gì mà đối tượng này có thểtiêu biểu cho những gì mà đối tượng này có thể làmDanh định dùng để phân biệt giữa các đối tượngDanh định dùng để phân biệt giữa các đối tượng ngay cả khi nó có cùng trạng thái và giá trị các thuộc tínhộ
64
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tính khả kiếnTính khả kiếnPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Nếu thuộc tính có tính khả kiến là công cộng (public +), thì nó có thể được nhìn thấy và sử dụng ngoài lớp đóNếu thuộc tính có tính khả kiến là riêng (private -), bạn sẽ không thể truy cập nó từ bên ngoài lớp đóNếu thuộc tính có tính khả kiến là bảo vệ (protected #) thìNếu thuộc tính có tính khả kiến là bảo vệ (protected #) thì cũng giống như thuộc tính có tính khả kiến là riêng nhưng là công cộng đối với các lớp con
65
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Biểu đồ lớp (class diagram)Biểu đồ lớp (class diagram)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Độc lập với ngôn ngữNhững ký hiệu cho phép đặc tả lớp, dữ liệu hay thuộc tính của chúng (private) và phương thức (method) ự thừ kế(method), sự thừa kế…Những sơ đồ đưa ra những hình ảnh về quan hệ cấu trúc và những ứng xử về chức năng của cáccấu trúc và những ứng xử về chức năng của các lớp
66
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Mục đích của biểu đồ lớpMục đích của biểu đồ lớpPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Làm tài liệu cho các lớp cấu thành hệ thống và hệ thốthống conMô tả kết hợp, tổng quát hóa và các quan hệ kết tập giữ á lớp t ong biể đồtập giữa các lớp trong biểu đồChỉ rõ đặc trưng của lớp, các thuộc tính và tác vụ chính của mỗi lớpchính của mỗi lớpBiểu đồ lớp được dùng khắp nơi trong chu trình phát triển từ bài toán đến mô hình cài đặtphát triển, từ bài toán đến mô hình cài đặt
67
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Các lớp dự tuyển (*)Các lớp dự tuyển (*)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
68
Nội dungNội dung
Biểu diễn Lớp và đối tượngBiể diễ hệ ( l ti hi )Biểu diễn quan hệ (relationship)
69
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Quan hệ (relationship)Quan hệ (relationship)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Kết hợp (Association)Kết tập (aggregation)Kết cấu (Composition)Phụ thuộc (Dependency)Chuyên biệt và tổng quát hóa (Specialization/Generalization)
70
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Kết hợp (Association)Kết hợp (Association)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Association Name
Professor UniversityWorks for
Role Names
Professor UniversityClass
EmployerEmployee
71
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Những ràng buộc của kết hợpNhững ràng buộc của kết hợpPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Một kết hợp phải có một tên đặt bên trên hay kề ới đườ liê hệvới đường liên hệ
Tên của kết hợp phải phản ảnh nội dung, là cụm động từ tên ó thể bỏ q đặ biệt khi tên i t òđộng từ, tên có thể bỏ qua đặc biệt khi tên vai trò của nó được dùng, tránh dùng tên không cộng thêm thông tinthêm thông tinMỗi đầu của kết hợp là một vai trò (role) chỉ ra vai trò của lớp trong kết hợp, tên vai trò phải là duytrò của lớp trong kết hợp, tên vai trò phải là duy nhất ứng với một lớp, tên vai trò phải là một danh từ đặt cuối đường kết hợp
72
Chọn một trong hai: tên kết hợp hay tên vai trò
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Vai tròVai tròPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Course plays two roles:• taught-by• managed-by
C L tt h t ht b
managed-by
Course
course_number: Stringcourse_name: Stringno of students: Integer
Lecturer
pnr: Integerstudent_name: StringIQ kvot: Integer
teaches
teaches taught-by
no_of_students: Integerteacher_name: String
Q_ g
manages
is_in_charge_of managed_by
One class may have many rolesOne class may have many roles.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Kết hợp đệ quiKết hợp đệ quiPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Tên vai trò là bắt buộc
74
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Association degreeAssociation degreeStudent
teaches
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTStudent
pnr: Integerstudent_name: StringIQ_kvot: Integer
A unary association
Course StudentA binary association
course_number: Stringcourse_name: Stringno_of_students: Integerteacher_name: String
pnr: Integerstudent_name: StringIQ_kvot: Integer
reads
An association may be unary binary or ternaryAn association may be unary, binary, or ternary
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Bản số (Multiplicity)Bản số (Multiplicity)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Xác định bao nhiêu đối tượng tham gia kết hợp
M
One or moreOne or more
Many
76
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Lớp kết hợp (Association class)Lớp kết hợp (Association class)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
1..* 0..*account card
dateIncluded
UsedFor
account
AssociationdateIncluded nclass
0..* 1..*student course
grade
student course
No Name
77
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Kết tập (aggregation)Kết tập (aggregation)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Kết tập là quan hệ giữa toàn bộ và bộ phậnMột đối tượ đượ t từ hữ đối tượ khá óMột đối tượng được tạo từ những đối tượng khác có tính vật lýMột đối tượng là tập hợp của những đối tượng khác cóMột đối tượng là tập hợp của những đối tượng khác có tính logicMột đối tượng chứa những đối tượng khác có tính vật lý
WholePart
Student SchedulePart
78
Aggregation
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Case study: Xác định lớp kết hợp (1)Case study: Xác định lớp kết hợp (1)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
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 Thisdifferent teachers may be involved on the course. This implies that these teachers may choose different course literature. The choice of the book does not only depend
th t h b t l th t d t ’ IQon the teacher, but also on the students’ average IQ value. A course may only start if there are at least 15 studentsA 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 expensivetoo expensive.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Case study: Xác định lớp kết hợp (2)Case study: Xác định lớp kết hợp (2)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
The courses are taught by lecturers. The fact that you are a lecturer does not hinder you from reading coursesare 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 sim ltaneo sl This is in cases hen the lect e is asimultaneously. This is in cases when the lecturer is a PhD student. The work he has put into developing and teaching on a course gives him credit point within his PhD studies.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTStudent
pnr: Integer
Teacher0..*Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTpnr: Integer
student_name: String$average_IQ: String
pnr: Integerlecturer_name: String…...
1..1
reads ↓
1..5
1..1taught_by ↑
1..5
Course Occassion
reads ↓
reads1..*
uses_book
start_date: Datefinish_date: Date Course Occassion
corresponds to the association class in an association of degree 4
Book
15..*1..*
offered_by ↑
association of degree 4.
Course
course_number: Integercourse_name: Stringcourse description: String
Book
book_number: IntegerISBN_number: Stringtitle: Stringprice: Real course_description: Stringprice: Real
1..1
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Composition (kết cấu)Composition (kết cấu)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Kết cấu là một dạng của kết tập, thời gian sống của đối tượng bộ phận không vượt quá thời giancủa đối tượng bộ phận không vượt quá thời gian sống của đối tượng toàn bộKhi toàn bộ bị xóa thì bộ phận cũng bị xóaKhi toàn bộ bị xóa thì bộ phận cũng bị xóaBộ phận có thể bị xóa trước khi toàn bộ bị xóa
St d t S h d l
Whole Part
Student Schedule
Aggregation
82
Aggregation
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Aggregation và compositionAggregation và compositionPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
83
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Chiều (Chiều (Navigation)Navigation)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
84
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Phụ thuộc (Dependency)Phụ thuộc (Dependency)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Một biến đổi trên một thành phần sẽ gây ra sự biến đổi trong thành phần khácbiến đổi trong thành phần khác
Client SupplierClass Component
Package Client SupplierDependency relationship
ClientPackage SupplierPackage
relationship
Dependency
85
relationship
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Specialization/GeneralizationSpecialization/GeneralizationPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Chuyên biệt hóa(/tổng quát hóa): là quá trình tinh chế một lớp thành những lớp chuyên biệt hơntinh chế một lớp thành những lớp chuyên biệt hơn. Chuyên biệt hóa bổ sung thêm chi tiết và đặc tả cho lớp kết quả. Lớp mang tính khái quát được gọi là lớ h ( l ) kế ả h ê biệ hólà lớp cha (superclass), kết quả chuyên biệt hóa là việc tạo ra các lớp con (Subclass).Tổng quát hóa và chuyên biệt liên quan tới ThừaTổng quát hóa và chuyên biệt liên quan tới Thừa kế (Inheritance)
Lớp con thừa kế attributes, operations, và relationshipsp p pLớp con có thể:• Cộng thêm attributes, operations, relationships
Xác định lại tác được thừa kế (ca tion!)
86
• Xác định lại tác vụ được thừa kế (caution!)
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Generalisation/specialisationGeneralisation/specialisationPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
PersonOften we find similar properties or terms in the Universe of Discourse, which however, are not
Student Teacher
, ,exactly the same
Class
ObjectObject
Sven Lund
Ulla RaskAnna Bok
Erik GaddOlle Macho
Erik Gadd
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Generalisation/specialisationGeneralisation/specialisationPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Person
Student Teacher
Class
ObjectObject
Sven LundUlla Rask
Anna Bok
Erik GaddOlle Macho
Erik Gadd
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTHandExistence dependencyExistence dependency
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTHand
is_part_of
has*Finger Transitivity
object A contains object B, and object B contains object C, then A contains C.
A tis_part_of
Asymmetryif A contains B, then B cannot contain ANail
has*
cannot contain A.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Phát triển phân cấp lớpPhát triển phân cấp lớpPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
90
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Phát triển phân cấp lớpPhát triển phân cấp lớpPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
91
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thừa kếThừa kếPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Person More generalAbstraction
Employee Customer Supplier
More general(superclasses)
monthly weekly hourly Subclasses are fully Consistent with monthly
paidy
paidy
paid super classes and add more information
Driver Cleaner Sales assistant More specialized
( b l )
information
R l ld titi (subclasses)Real-world entities on leaves
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thừa kế (Inheritance) và tổng quát hóaThừa kế (Inheritance) và tổng quát hóaPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
93
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thừa kế đơnThừa kế đơnPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Ancestor
AccountbalancenamenumberSuperclass number
Withdraw()CreateStatement()
Superclass (parent)
GeneralizatioGeneralization Relationship
Checking
Withdraw()
Savings
GetInterest()Withdraw()
Subclasses
94
Withdraw()
Descendents
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Đa thừa kếĐa thừa kếPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
FlyingThing Animal
multipleinheritance
Airplane Helicopter Wolf HorseBird
Use multiple inheritance only when needed, and always with caution !
95
always with caution !
Ví dụVí dụ
G dV hi lGroundVehicleweightlicenseNumber
owner Person
0..* 1Superclass (parent)
register( )generalization
Trucktonnage
Car Trailer
Subclass size
getTax( )
96
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Lớp trừu tượngLớp trừu tượngPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Person(abstract)
pnr: Integername: Stringbirth_date: Integeraddress: String Abstract classes
hi hcreate a high-level modelling vocabulary
Student
IQ-value: Integert d t i t I t
Teacher
Ped_skill: Integeri I t
vocabulary.
student_points: Integer experience: Integer
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Ràng buộcRàng buộcPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Cho phép cộng thêm ngữ nghĩa mớiRà b ộ là ột St i đó t ặ hRàng buộc là một String đóng trong ngoặc nhọn đặt gần thành phần mà nó áp dụngDù hệ h th ộ ế ó hiề thà h hầDùng quan hệ phụ thuộc nếu có nhiều thành phần mà ràng buộc áp dụng
MemberProfessor Department
Deparment Head
{Subset}
98
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Phân loại trong Kế thừaPhân loại trong Kế thừaPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
4 loại (ràng buộc)DisjointOverlappingCompleteIncomplete
99
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thừa kế và tổng quát hóaThừa kế và tổng quát hóaPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
100
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Phân loạiPhân loạiPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
StudentOverlappingDisjoint?Member
Internal Local
pp g?
j
Staff Student
Student
DiscriminatorStudent
mode typeComplete?PGrads
UGrads
Local
L lPG d
Student
Asian Local
International
LocalPGrads
s a oca
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Xác định aggregationXác định aggregationPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Sometimes, the teachers cannot utilise the h l b k d i th i l twhole books during their courses, only parts
of it. This is because for some courses it may be difficult to find an optimal book. Not every p yteacher has time to write specifically tailored own material. Hence, the teaching material consists of different book chapters or evenconsists of different book chapters or even book sections. Due to the fact that the material conveyed in these books may quickly
(t i l ithi t i ) thage (typical within computer science), the constellation of the teaching material often changes. g
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTBook 0..* Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
is_part_of1..1
has1..*0..*
Chapter Course Literature0..* 1..*
is_part_of
1 *
1..1
0..*
Sectionhas1..
0..*
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Study case: generalisation/specialisation (1)Study case: generalisation/specialisation (1)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
The teaching material does not only consist of booksThe teaching material does not only consist of books. Teaching material can be anything:- books, or parts of books as has already been modelled. - national publications, such as technical reports and working articlesworking articles.- different kinds of international publications such as journal-, conference- or workshop papers.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Study case: generalisation/specialisation (2)Study case: generalisation/specialisation (2)Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
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.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,
i t t I dditi h i f t d tassistants. In addition, we have varying groups of students. We have Swedish and foreign exchange students. Regarding the Swedish students, they need not be necessarily originally , y y g ySwedish. The prerequisite for being classified as a Swedish student is that the student lives permanently in Sweden.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Study case: biểu đồStudy case: biểu đồPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Course Literature
PublicationBook
is_part_of1..1
0..*Publication
Chapter
has1..*
0..*
0..*
1..* Book Literature
NationalPublication
International Publication
is_part_of
h1 *
1..10..*
Literature
TechnicalReport
WorkingPaper
ConferenceArticle
JournalArticle
Workshop
Section
has1..
0..*
Report Paper Article Article pArticle
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Biểu đồBiểu đồPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
EducationalMaterial
CourseLiterature
0..*0..*
Book
is part of1 1
0..*Publication0..*
Chapter
is_part_of
has1..*
1..1
0..*
0..*
1..* BookLiterature
NationalPublication
International Publication
0..*
is_part_of
has1..*
1..10..*
Literature
TechnicalReport
WorkingPaper
ConferenceArticle
JournalArticle
WorkshopArticle
Section 0..*
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Biểu đồ lớp PersonBiểu đồ lớp PersonPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
SU also wishes to know all the roles involved in teaching. They are course leaders,
Person
course executors, advisors, course developers, assistants. In addition, we have varying group of students.
T hiStudent TeachingStaff
SwedishStudent
ForeignStudent
Courseleader
Course Executor
Advisor Assistant
NativeSwedish
Non-nativeSwedishSwedish
Student Student
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Bài tậpBài tậpPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Books and journals The library contains booksand 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 libraryAll other books may be borrowed by any library member for three weeks. Members of the librarycan 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 journalsjournals.Borrowing The system must keep track of when books and journals are borrowed and returned,
109
books and journals are borrowed and returned, enforcing the rules described above.
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
UML/NN110
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐTPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
UML/NN111
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Biểu đồ lớp quản lý thuê xeBiểu đồ lớp quản lý thuê xePhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
VDVDPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
UML/NN113
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Câu hỏiCâu hỏiPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Giải thích một số khái niệm về hướng đối tượng?Khác biệt giữa lớp và đối tượng ?Lớp dẫn xuất ?Lớp kế thừa những gì ?Quan hệ của lớp ? Các loại quan hệ ? Ràng buộc giữa các quan hệ ?Phân loại trong kế thừa? ạ g
114
Phân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Thực hànhThực hànhPhân tích Thiết kế HĐTPhân tích Thiết kế HĐT
Phát hiện thực thể và các tương tác của các hệ thốthống
Hệ thống Thay thế tài xếHệ thố Khả thíHệ thống Khảo thíHệ thống Quản lý khoHệ thố S f HHệ thống Safe HomeHệ thống Thư viện trực tuyếnHệ thống ATMHệ thống ATMHệ thống Đấu giáHệ thống Tính công Xí nghiệp mayHệ thống Tính công Xí nghiệp may…
115