Tải bản đầy đủ (.pdf) (32 trang)

Tài liệu Phân tích thiết kế hệ thống hướng đối tượng dùng UML - Module 12: Thiết kế Subsystem pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (210.42 KB, 32 trang )

PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
1
Phân tích và Thiết kế Hướng đối tượng
dùng UML
Module 12: Thiết kế Subsystem
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
2
Mục tiêu:
w Tìm hiêu mục đích của bước thiết kế
Subsystem và vò trí của công đoạn này trong
qui trình
w Đònh nghóa các hành vi đươc mô tả trong
interfaces của subsystem dưới dạng
collaboration của các class chưa bên trong
w Lập sưu liệu về cấu trúc bên trong của
subsystem
w Xác đònh các phụ thuộc cào các phần tử bên
ngoài subsystem
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
3
Vò trí của Thiết kế Subsystem
Architect
Designer
Architectural
Analysis
Architecture
Reviewer
Review the


Design
Review the
Architecture
Use-Case
Analysis
Architectural
Design
Describe
Concurrency
Describe
Distribution
Class
Design
Subsystem Design
Use-Case
Design
Design
Reviewer
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
4
Tổng quan về thiết kế Subsystem
Subsystem
Design
Use-Case Realization Use-Case Realization
(updated)
Design Subsystems and Interfaces
Design Subsystems and Interfaces
(updated)
Design Classes

Design
Guidelines
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
5
w Subsystem là sự “kết hợp” giữa package và
class
w Hiện thực hóa 1 hoặc nhiều interfaces đònh
nghóa hành vi của nó
<<subsystem>>
Subsystem Name
Interface Subsystem
<<subsystem>>
Subsystem Name
Interface
Realization (Canonical form)
Realization (Elided form)
<<interface>>
Interface
Nhắc lại: Subsystems và Interfaces
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
6
Chìa khóa là abstraction và encapsulation
A
<<subsystem>>
B
<<subsystem>>
C
<<subsystem>>

Subsystem Guidelines
w Mục tiêu
§ Giảm thiểu kết nối
§ Có tính cơ động, tương thích plug-and-play
§ Cách ly các thay đổi
§ Tiến hóa độc lập
w Những đề nghò
§ Đừng khảo sát chi tiết, chỉ interfaces
§ Chỉ phụ thuộc vào interfaces khác
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
7
Nhắc lại: Các qui ước mô hình hóa
CourseCatalogSystem
<<subsystem>>
ICourseCatalogSystem
ICourseCatalogSystem
CourseCatalogSystem
<<subsystem proxy>>
CourseCatalogSystem
<<subsystem>>
Interfaces start with an “I”
<<subsystem>> package
<<subsystem proxy>> class
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
8
Các bước thiết kế Subsystem
w Phân bố các hành vi của Subsystemcho các
phần tử của nó

w Lập sưu liệu về các phần tử của Subsystem
w Mô tả các phụ thuộc của Subsystem
w Checkpoints
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
9
Các bước thiết kế Subsystem
w Phân bố các hành vi của Subsystemcho các
phần tử của nó
w Lập sưu liệu về các phần tử của Subsystem
w Mô tả các phụ thuộc của Subsystem
w Checkpoints
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
10
CourseCatalogSystem
<<subsystem>>
ICourseCatalogSystem
getCourseOfferings()
<<interface>>
subsystem responsibility
Các nhiệm vụ của Subsystem
w Các interface operation xác đònh nhiệm vụ của
Subsystem
w Interface operations được hiện thực hóa bởi
§ Internal class operations
§ Internal subsystem operations
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
11

Phân bố nhiệm vụ của Subsystem
w Xác đònh các phân tử thiết kế mới, hoặc dùng lại
cái có sẵn, (chẳng hạn, các class hay subsystem)
w Gán trách nhiệm của subsystem cho các phần tử
của nó
w Tích hợp các cơ chế khả dụng (persistence,
distribution, …)
w Lập sưu liệu về collaboration giữa các phần tử thiết
kế trong “interface realizations”
§ Một hay nhiều interaction diagrams/interface
operation
§ Class diagram(s) chứa các quan hệ cần thiết
w Tham khảo lại phần thiết kế kiến trúc
§ Chỉnh subsystem boundaries và các phụ thuộc,
nếu cần
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
12
Qui ước: Subsystem Interaction Diagrams
Subsystem Client
Subsystem Proxy
Design Element 1
performResponsibility( )
Op1()
subsystem responsibility
Op2()
Design Element 2
Op3()
Op4()
Internal subsystem

interactions
Không hiển thò Subsystem interface
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
13
Ví dụ: CourseCatalogSystem Subsystem
subsystem interface
: Student
: RegisterFor
CoursesForm
: Registration
Controller
: Schedule : Student: ICourseCatalog
System
A list of the available
course offerings for this
semester are displayed
Student wishes to
create a new
schedule
1: // create schedule( )
4: // display course offerings( )
2: // get course offerings( )
9: // add schedule(Schedule)
3: getCourseOfferings(Semester)
5: // display blank schedule( )
At this, point the Submit Schedule subflow is executed.
6: // select 4 primary and 2 alternate offerings( )
7: // create schedule with offerings( )
8: // create with offerings( )

A blank schedule
is displayed for the
students to select
offerings
subsystem responsibility
Legacy RDBMS Database Access
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
14
Analysis Class Analysis Mechanism(s)
Student
CourseOffering
Course
RegistrationController
Persistency, Security
Persistency, Legacy Interface
Persistency, Legacy Interface
Distribution
Tích hợp cơ chế kiến trúc: Persistency
w Bảng ánh xạ Analysis-Class với các cơ chế
kiến trúc có từ phân tích Use-Case
Schedule Persistency, Security
OODBMS Persistency đã khảo sát
trong Use-Case Design
OODBMS
Persistency
RDBMS
Persistency
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức

15
w Cung cấp khả năng truy suất đến thư viện các class cần
để cài đặt JDBC
§ Cung cấp java.sql package
w Tạo các DBClass cần thiết
§ Một DBClass/một persistent class
§ Course Offering persistent class =>
DBCourseOffering
Nhắc lại: Các bước tích hợp JDBC

√ - Done
(còn tiếp)
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
16
w Tích hợp các DBClass vào thiết kế
§ Gán cho các package/layer
• DBCourseOffering đặt vào
CourseCatalogSystem subsystem
§ Thêm các quan hệ với persistency clients
• Persistency clients là CourseCatalogSystem
subsystem clients
w Tạo/Hiệu chỉnh các interaction diagram mô tả:
§ Việc khởi tạo Database
§ Truy xuất đến Persistent class: Create, Read,
Update, Delete
Nhắc lại: Các bước tích hợp JDBC (tt.)
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
17

Ví dụ: Local CourseCatalogSystem Subsystem Interaction
Subsystem Proxy
RDBMS
Read
Retrieve all available course
offerings for the current
semester
CourseCatalog
System Client
:
CourseCatalogSystem
:
DBCourseOfferring
:
CourseOffering
:
CourseOfferingList
: ResultSet
: Course Catalog
: Statement: Connection
1. getCourseOfferings(Semester)
1.1. read(string)
1.1.1. createStatement( )
1.1.2. executeQuery(String)
sql statement is passed in
specifying the search criteria
course offerings in the current
semester
1.1.4. new( )
Repeat these operations for each

element returned from the
executeQuery() command.
The CourseOfferingList is loaded
with the data retrieved from the
database.
The getData and setData
operations are called for each
attribute in the each retrieved
class instance.
3. setData( )
Create a list to hold all
retrieved course offerings
Add the retrieved course offering
to the list to be returned
2. getString( )
1.1.3. new( )
4. add(CourseOffering)
1.1.2.1. // executeQuery( )
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
18
Ví dụ: Billing System Subsystem
Send student and tuition to
the Billing System, which will
do the actual billing to the
student for the schedule.
: Registrar
:
CloseRegistrationForm
:

CourseOffering
: Schedule : Student. :
IBillingSystem
:
ICourseCatalogSystem
:
CloseRegistrationController
Close
registration for
each course
offering
Retrieve a list of course
offerings for the current
semester
If the maximum number of
selected primary courses have
not been committed, select
alternate course offerings).
Currently assuming tuition based on
number of offerings taken and certain
attributes of students. If different offerings
get different prices this will change slightly.
Repeat twice this is
for simplicity;
realistically, an
indefinite number of
iterations could
occur)
Finally commit or
cancel the course

offering once all
leveling has occurred
1. // close registration( )
2. // close registration( )
2.2. // close registration( )
1.1. // is registration open?( )
2.6. submitBill(Student, double)
2.3. // level( )
2.1. getCourseOfferings(Semester)
2.4. // close( )
2.5. getTuition( )
subsystem interface
subsystem responsibility
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
19
Ví dụ: Local BillingSystem Subsystem Interaction
Billing System
Client
:
BillingSystem
:
StudentBillingTransaction
:
BillingSystemInterface
: Billing System
: Student.
1. submitBill(Student, double)
1.1. create(Student, double)
1.2. submit(StudentBillingTransaction)

1.1.1. // get contact info( )
Retrieve the
information that must
be included on the bill
1.2.1. // open connection( )
1.2.2. // process transaction( )
1.2.3. // close connection( )
Subsystem Proxy
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
20
Các bước thiết kế Subsystem
w Phân bố các hành vi của Subsystemcho các
phần tử của nó
w Lập sưu liệu về các phần tử của Subsystem
w Mô tả các phụ thuộc của Subsystem
w Checkpoints
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
21
Ví dụ: CourseCatalogSystem Subsystem Elements
Subsystem Proxy
Subsystem Interface
DBCourseOfferring
create() : CourseOffering
read(searchCriteria : string) : CourseOfferingList
CourseCatalogSystem
getCourseOfferings(forSemester : Semester) : CourseOfferingList
<<subsystem proxy>>
ICourseCatalogSystem

getCourseOfferings(forSemester : Semester) : CourseOfferingList
(from External System Interfaces)
<<Interface>>
Statement
executeQuery()
executeUpdate()
(from java.sql)
Connection
createStatement()
(from java.sql)
1
1
CourseOfferingList
new()
add()
(from University Artifacts)
CourseOffering
new()
setData()
(from University Artifacts)
<<entity>>
1
0 *
ResultSet
getString()
(from java.sql)
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
22
Ví dụ: Billing System Subsystem Elements

StudentBillingTransaction
create(forStudent : Student, forAmount : double)
Student.
// get contact info()
(from University Artifacts)
<<entity>>
BillingSystem
submitBill(forStudent : Student, forTuition : double)
<<subsystem proxy>>
BillingSystemInterface
submit(theTransaction : StudentBillingTransaction)
0 1
1
0 1
1
IBillingSystem
submitBill()
(from External System Interfaces)
<<Interface>>
Subsystem Proxy
Subsystem Interface
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
23
Các bước thiết kế Subsystem
w Phân bố các hành vi của Subsystemcho các
phần tử của nó
w Lập sưu liệu về các phần tử của Subsystem
w Mô tả các phụ thuộc của Subsystem
w Checkpoints

PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
24
Mềm dẻo
Describing Subsystem Dependencies
w Subsystem phụ thuộc vào một subsystem
w Subsystem phụ thuộc vào package
Server
Client Support
<<subsystem>>
Server Support
<<subsystem>>
Dùng nhưng cẩn
thận
Client Support
<<subsystem>>
Supporting
Types
PT & TK Hướng đối tượng – Thiết kế kiến trúc
Dương Anh Đức
25
Ví dụ:
CourseCatalogSystem Subsystem
Dependencies
java.sql
(from Middleware)
CourseCatalogSystem
(from Business Services)
<<subsystem>>
External System

Interfaces
(from Business Services)
University Artifacts
(from Business Services)

×