Upload
guest786ab5
View
4.847
Download
4
Embed Size (px)
Citation preview
PGS.TS. Đặng Văn ĐứcEmail: [email protected]
VIỆNVIỆN CÔNG CÔNG NGHỆ THÔNG TINNGHỆ THÔNG TIN
VIỆN KHOA HỌC VÀ CÔNG NGHỆ VIỆT NAM
PHÂN TÍCH THIẾT KẾ PHÂN TÍCH THIẾT KẾ HƯỚNG ĐỐI TƯỢNGHƯỚNG ĐỐI TƯỢNG
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 2/43
NỘI DUNGNỘI DUNG
1. Tiến trình phát triển phần mềm theo hướng đối tượngGiới thiệu Ngôn ngữ mô hình hóa thống nhất UML
3. Mô hình hóa nghiệp vụ4. Mô hình hóa trường hợp sử dụng 5. Mô hình hóa tương tác đối tượng6. Biểu đồ lớp và gói7. Biểu đồ chuyển trạng thái và biểu đồ hoạt động8. Biểu đồ kiến trúc vật lý và phát sinh mã trình9. Mô hình hóa dữ liệu10.Bài học thực nghiệm
Giới thiệu Giới thiệu Ngôn ngữ mô hình hóa thống nhấtNgôn ngữ mô hình hóa thống nhất
Bài 2
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 4/43
Mô hình là gì?
Mô hình là bức tranh hay mô tả vấn đề đang cố gắng giải quyết hay mô tả chính giải pháp vấn đề
là ngôn ngữ của người thiết kế (trong nhiều lĩnh vực)
là trình diễn hệ thống sẽ xây dựng
là phương tiện giao tiếp giữa các stakeholders
là kế hoạch chi tiết (blueprints)
Mô hình cho khả năng suy diễn một số đặc tính của hệ thống thực
Mô hình hóa trực quanBằng các phần tử đồ họa
Ngôn ngữ mô hình hóa là ngôn ngữ mô tả hệ thống hay tác nghiệp
An abstraction is an intellectual simplification
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 5/43
Thí dụ mô hình
Thế giới thực
Ôtô Con người SáchĐọcLàm chủMô hình
Thế giới thực
Mô hình: Quả địa cầu học sinh
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 6/43
Thí dụ mô hình
A model is a completedescription of a systemfrom a particularperspective
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 7/43
Mô hình hóa trực quan?
Computer System
Business Process
Order
Item
Ship via
“Modeling captures essential parts of the system.”
Dr. James Rumbaugh
Visual Modeling is modelingusing standard graphical notations
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 8/43
Bốn nguyên tắc mô hình hóa
Việc chọn mô hình nào để tạo lập có ảnh hưởng sâu sắc đến cách giải quyết vấn đề và cách hình thành các giải pháp
Mỗi mô hình biểu diễn hệ thống với mức độ chính xác khác nhau
Mô hình tốt nhất phải là mô hình phù hợp với thế giới thực
Không mô hình nào là đầy đủ. Mỗi hệ thống thường được tiếp cận thông qua tập mô hình gần như độc lập nhau.
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 9/43
Thiết kế kiến trúc
ArchitectureQualities
Process
Architecture Representation
The “what” The “why”
The “how”The “who”
SystemFeatures
Architecture S/W Requirements
SystemQuality Attributes
Satisfies
Constrain
Organization
Architect
Skills
Stakeholders
Defines role
Produces
Follows
DefinesTechnology
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 10/43
Ngôn ngữ mô hình hóa thống nhất
Unified Method 0.8OOPSLA ´95
Booch method OMT OOSEOther methods
UML 0.9June ´96
publicfeedback
Final submission to OMG, Sep ‘97
First submission to OMG, Jan ´97UML 1.1
OMG Acceptance, Nov 1997UML 1.3
UML 1.0UML partners
June 12, 2003 UML 2.0
UML stands for Unified Modeling Language
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 11/43
UML Partners
Rational Software CorporationHewlett-PackardI-LogixIBMICON ComputingIntellicorpMCI SystemhouseMicrosoftObjecTimeOraclePlatinum TechnologyTaskonTexas Instruments/Sterling SoftwareUnisys
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 12/43
Contributions to the UMLMeyer
Before and after conditions
HarelStatecharts Gamma, et al
Frameworks and patterns,
HP FusionOperation descriptions and message numbering
EmbleySingleton classes andhigh-level view
Wirfs-BrockResponsibilities
OdellClassification
Shlaer - MellorObject lifecycles
RumbaughObject Modeling
Technique
BoochBooch method
JacobsonObject-Oriented
Software Engineering
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 13/43
Khái quát về UML
UML là ngôn ngữ đểvisualizingspecifyingconstructingdocumenting
các vật phẩm (artifacts) của hệ thống phần mềm
Nó có thể sử dụng trong mọi tiến trình, xuyên suốt vòng đời phát triển và trải qua các công nghệ cài đặt khác nhau.
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 14/43
Khái quát về UML
Mô hình hóa các phần tửCác quan hệCơ chế mở rộngCác biểu đồ
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 15/43
Mô hình hóa các phần tử
Các phần tử cấu trúcclass, interface, collaboration, use case, active class, component, node
Các phần tử hành viinteraction, state machine
Nhóm các phần tủpackage, subsystem
Các phần tử khácnote
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 16/43
Các quan hệ
DependencyAssociationGeneralizationRealization
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 17/43
Cơ chế mở rộng
StereotypeTagged valueConstraint
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 18/43
Models and Diagrams
Use CaseDiagrams
ScenarioDiagramsScenario
DiagramsCollaborationDiagrams
ComponentDiagrams
DeploymentDiagrams
ObjectDiagrams
ScenarioDiagramsScenario
DiagramsStatechartDiagrams
SequenceDiagrams
ClassDiagrams
ActivityDiagrams
Models
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 19/43
Diagrams
A diagram is a view into a modelPresented from the aspect of a particular stakeholderProvides a partial representation of the systemIs semantically consistent with other views
In the UML, there are nine standard diagramsStatic views: use case, class, object, component, deploymentDynamic views: sequence, collaboration, statechart, activity
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 20/43
Workflows and Models
Requirements
Design
Implementation
Test
Analysis
Use CaseModel
DesignModel Depl.
Model
Impl.Model
AnalysisModel
TestModel
UML diagrams provide views into each model
Each workflow is associated with one or more models.
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 21/43
Representing System Architecture
Conceptual Physical
Logical View
End-user Functionality
Implementation View
Programmers Software management
Process View
PerformanceScalabilityThroughput
System integrators
Deployment View
System topology Delivery, installation
Communication
System engineering
Use Case View
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 22/43
Cần bao nhiêu khung nhìn?
Mô hình phù hợp với ngữ cảnh phát triển hệ thống
Không phải tất cả các mô hình đòi hỏi đầy đủ khung nhìnĐơn xử lý: Bỏ qua khung nhìn triển khai
Đơn tiến trình: Bỏ qua khung nhìn tiến trình
Chương trình rất nhỏ: Bỏ qua khung nhìn cài đặt
Bổ sung các khung nhìnData view
Security view
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 23/43
UML Concepts
UML được sử dụng để:Hiển thị biên hệ thống và các chức năng chính của nó bằng usecases và actors
Mô tả hiện thực use case bằng interaction diagrams
Biểu diễn các cấu trúc tĩnh của hệ thống bằng class diagrams
Mô hình hóa hành vi đối tượng bằng state transition diagrams
Biểu thị kiến trúc cài đặt vật lý bằng component & deployment diagrams
Mở rộng các chức năng bằng stereotypes
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 24/43
Thí dụ ứng dụng UML
Một trường đại học thực hiện tin học hóa hệ thống đăng ký học và dạy học:
Giáo vụ (Registrar) lập chương trình giảng dạy (curriculum) cho một học kỳSinh viên (Student) chọn 4 môn học chính và 2 môn dự bịKhi sinh viên đăng ký học thì hệ thống thanh toán (billing system) in hóa đơn học phí cho sinh viênSinh viên có thể sử dụng hệ thống để bổ sung/loại bỏ môn học saukhi đã đăng ký (trong khoảng thời gian cố định)Giáo sư (Professors) sử dụng hệ thống để xem bảng phân công dạy học (course rosters)Người sử dụng hệ thống đăng ký được cấp passwords để vào máy
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 25/43
Use case Diagram
Student
Registrar
Professor
Maintain Schedule
Maintain Curriculum
Request Course Roster
Billing System
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 26/43
Use case Diagram
Use case diagrams are created to visualize the relationships between actors and use casesCaptures system functionality as seen by usersBuilt in early stages of developmentPurpose
Specify the context of a systemCapture the requirements of a systemValidate a system’s architectureDrive implementation and generate test cases
Developed by analysts and domain experts
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 27/43
Sequence Diagram
: Student registration form
registration manager
math 101
1: fill in info
2: submit
3: add course(joe, math 01)
4: are you open?5: are you open?
6: add (joe)7: add (joe)
math 101 section 1
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 28/43
Sequence Diagram
A sequence diagram displays object interactions arranged in a time sequenceCaptures dynamic behavior (time-oriented)Purpose
Model flow of controlIllustrate typical scenarios
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 29/43
Collaboration Diagram
: Registrar
course form : CourseForm
theManager : CurriculumManageraCourse :
Course
1: set course info2: process
3: add course
4: new course
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 30/43
Collaboration Diagram
A collaboration diagram displays object interactions organized around objects and their links to one anotherCaptures dynamic behavior (message-oriented)Purpose
Model flow of controlIllustrate coordination of object structure and control
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 31/43
Class Diagram
RegistrationForm
RegistrationManager
Course
Student
CourseOfferingProfessor
addStudent(Course, StudentInfo)
namenumberCredits
open()addStudent(StudentInfo)
major
location
open()addStudent(StudentInfo)
tenureStatus
ScheduleAlgorithm
10..*
0..*
1
1
1..*4
3..10
0..41
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 32/43
Class Diagram
A class diagram shows the existence of classes and their relationships in the logical view of a systemCaptures the vocabulary of a systemBuilt and refined throughout developmentPurpose
Name and model concepts in the systemSpecify collaborationsSpecify logical database schemas
Developed by analysts, designers, and implementers
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 33/43
Object Diagram
Shows instances and linksBuilt during analysis and designPurpose
Illustrate data/object structuresSpecify snapshots
Developed by analysts, designers, and implementers
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 34/43
State Transition Diagram
Initialization Openentry: Register studentexit: Increment count
Closed
Canceled
do: Initialize course
do: Finalize course
do: Notify registered students
Add Student / Set count = 0
Add student [count < 10]
[count = 10]
Cancel
Cancel
Cancel
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 35/43
State Transition Diagram
State transition diagrams are created for objects with significant dynamic behaviorCaptures dynamic behavior (event-oriented)Purpose
Model object lifecycleModel object lifecycleModel reactive objects (user interfaces, devices, etc.)Model reactive objects (user interfaces, devices, etc.)
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 36/43
Activity Diagram
Captures dynamic behavior (activity-oriented)Purpose
Model business workflowsModel operations
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 37/43
Component Diagram
Course CourseOffering
Student Professor
Course.dll
People.dll
Course
User
Register.exeBilling.exe
BillingSystem
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 38/43
Component Diagram
Component diagrams illustrate the organizations and dependencies among software componentsCaptures the physical structure of the implementationBuilt as part of architectural specificationPurpose
Organize source codeConstruct an executable releaseSpecify a physical database
Developed by architects and programmers
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 39/43
Deployment Diagram
Registration Database
Library
Dorm
Main Building
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 40/43
Deployment Diagram
Client
Server
ApplicationServer
FulfillmentSystem
FinancialSystem
InventorySystem
RDBMSServer
Dynamic HTML, JavaScript, Javaplug-ins, source code enhancements
Java, C, C++, JavaScript, CGI
Java, C, C++, JavaBeans, CORBA, DCOM
Native languages
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 41/43
Deployment Diagram
The deployment diagram shows the configuration of run-time processing elements and the software processes living on themCaptures the topology of a system’s hardwareBuilt as part of architectural specificationPurpose
Specify the distribution of componentsIdentify performance bottlenecks
Developed by architects, networking engineers, and system engineers
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 42/43
Rational Rose
Rose is available in three editions: Rose Modeler – no language supportRose Professional – support for 1 languageRose Enterprise – supports multiple languages including (VC++, VB, Java, CORBA and XML)
Why should we use Rational Rose?Common standard language--the Unified Modeling Language (UML) --results in improved team communicationReverse-engineering capabilities allow you to integrate with legacy OO systemsModels and code remain synchronized through the development cycle... Demo Rose
dvduc-2004 Phân tích thiết kế hướng đối tượng Bài 2 - 43/43
Tóm tắt
Các vấn đề đã nghiên cứuKhái niệm mô hình, mô hình hóa trực quanKhái quát về Ngôn ngữ mô hình hóa thống nhấtThí dụ sử dụng các biểu đồ của UML