This document discusses SOLID principles, dependency inversion, dependency injection, and AutoMapper. It covers the benefits of loose coupling code using dependency injection such as improved testability and separation of concerns, as well as potential downsides like increased complexity. It provides examples of dependency injection frameworks like Unity and Ninject and demonstrates how AutoMapper can simplify mapping between objects.
This document discusses SOLID principles, dependency inversion, dependency injection, and AutoMapper. It covers the benefits of loose coupling code using dependency injection such as improved testability and separation of concerns, as well as potential downsides like increased complexity. It provides examples of dependency injection frameworks like Unity and Ninject and demonstrates how AutoMapper can simplify mapping between objects.
This document provides an introduction to printing and reporting features in Rational Rose 98i. It outlines objectives to print diagrams and specifications and use reports, including usage reports, instance reports, access violation reports, SODA reports, participant reports, and documentation reports. The document describes setting printer options, printing diagrams and specifications, viewing page breaks, and generating various reports. It concludes with an exercise to run the different reports.
RoseScript is a scripting language that allows users to automate tasks and customize Rational Rose by accessing and modifying model elements. It can be used to extract information from models, generate reports, integrate with other tools, and make changes to models such as adding or renaming packages and classes. The document provides an overview of RoseScript concepts and capabilities as well as examples of scripts that obtain information from and make changes to Rose models.
The document discusses team development using Rational Rose and configuration management. It describes how to:
1. Create controlled units to partition the model and place components under configuration control.
2. Define an integration workspace and developer workspaces using a configuration management system like ClearCase.
3. Determine which model components should be controlled units and provide access to configuration management tools within Rational Rose.
This document provides an introduction to creating component and deployment diagrams in Rational Rose 98i. It discusses how to create packages, components, and map classes to components. It also covers how to create relationships between components, component diagrams, deployment diagrams, and their various stereotypes. Exercises are included to allow the user to practice creating components, mapping classes, and building component and deployment diagrams.
This document provides an introduction to activity diagrams in Rational Rose 98i. It outlines the objectives of understanding activity diagrams which are to create them, add activities and transitions between activities, model concurrent flows and decisions, and use swimlanes. It also describes the key elements of an activity diagram like activities, transitions, start and end states, forks, joins, decisions, and swimlanes. The document aims to teach the user how to construct basic activity diagrams in Rational Rose 98i.
This document provides an introduction to state diagrams in Rational Rose 98i. It outlines the objectives of learning to create state diagrams containing states, transitions, actions and nested states. It describes the various tools and elements used to build state diagrams, including states, transitions, actions, start and end states, and nested states. The document concludes with an exercise to create a state diagram.
This document provides an introduction to creating collaboration diagrams in Rational Rose 98i. It outlines how to create objects from classes, link objects with messages between them, and map messages to class operations. It notes that while objects and links can be created, messages cannot be moved or inserted in a collaboration diagram, requiring the use of a sequence diagram instead to rearrange messages as needed before switching back to the collaboration diagram. The document includes exercises for the reader to practice these skills by creating sample collaboration and sequence diagrams.
This document provides an introduction to sequence diagrams in Rational Rose 98i. It outlines how to create a sequence diagram, assign objects to classes, add and manipulate messages between objects, and create scripts and collaboration diagrams based on the sequence diagram. The objectives are to learn how to create a sequence diagram, assign objects, map messages to operations, create scripts, and generate a collaboration diagram from the sequence diagram.
This document provides an introduction to class diagrams in Rational Rose 98i. It covers how to create classes, add attributes and operations, define relationships between classes, and use packages to organize classes. The key elements of a class diagram - classes, interfaces, packages and relationships - are described. Guidelines are provided for documenting classes, applying stereotypes, and setting attribute and operation visibility. The document concludes with exercises for creating example class diagrams.
The document introduces use case diagrams, which show the functionality of a system and how it interacts with external actors. It discusses creating actors and use cases, documenting use cases, and relationships between use cases and actors. The exercises at the end instruct the reader to create a use case diagram based on example pictures and documentation.
Rational Rose 98i is a UML modeling tool that supports different views like use case, interaction, logical, component and deployment views. It allows creating models with packages, classes, use cases and other elements. The user interface consists of toolbars, browser, documentation window and diagram windows. Pathmaps and options can be configured for team development.
This document provides an introduction and outline for a course on using Rational Rose 98i Version 5.2. The course is intended for anyone needing to learn the capabilities of Rational Rose. Upon completion, participants will be able to use Rational Rose to document software projects, understand team development strategies, create scripts using RoseScript, and generate reports. The course outline covers creating various UML diagrams like use case diagrams, class diagrams, sequence diagrams, collaboration diagrams, state diagrams, activity diagrams, component diagrams, and deployment diagrams. It also covers team development and scripting.
This document provides an introduction to printing and reporting features in Rational Rose 98i. It outlines objectives to print diagrams and specifications and use reports, including usage reports, instance reports, access violation reports, SODA reports, participant reports, and documentation reports. The document describes setting printer options, printing diagrams and specifications, viewing page breaks, and generating various reports. It concludes with an exercise to run the different reports.
RoseScript is a scripting language that allows users to automate tasks and customize Rational Rose by accessing and modifying model elements. It can be used to extract information from models, generate reports, integrate with other tools, and make changes to models such as adding or renaming packages and classes. The document provides an overview of RoseScript concepts and capabilities as well as examples of scripts that obtain information from and make changes to Rose models.
The document discusses team development using Rational Rose and configuration management. It describes how to:
1. Create controlled units to partition the model and place components under configuration control.
2. Define an integration workspace and developer workspaces using a configuration management system like ClearCase.
3. Determine which model components should be controlled units and provide access to configuration management tools within Rational Rose.
This document provides an introduction to creating component and deployment diagrams in Rational Rose 98i. It discusses how to create packages, components, and map classes to components. It also covers how to create relationships between components, component diagrams, deployment diagrams, and their various stereotypes. Exercises are included to allow the user to practice creating components, mapping classes, and building component and deployment diagrams.
This document provides an introduction to activity diagrams in Rational Rose 98i. It outlines the objectives of understanding activity diagrams which are to create them, add activities and transitions between activities, model concurrent flows and decisions, and use swimlanes. It also describes the key elements of an activity diagram like activities, transitions, start and end states, forks, joins, decisions, and swimlanes. The document aims to teach the user how to construct basic activity diagrams in Rational Rose 98i.
This document provides an introduction to state diagrams in Rational Rose 98i. It outlines the objectives of learning to create state diagrams containing states, transitions, actions and nested states. It describes the various tools and elements used to build state diagrams, including states, transitions, actions, start and end states, and nested states. The document concludes with an exercise to create a state diagram.
This document provides an introduction to creating collaboration diagrams in Rational Rose 98i. It outlines how to create objects from classes, link objects with messages between them, and map messages to class operations. It notes that while objects and links can be created, messages cannot be moved or inserted in a collaboration diagram, requiring the use of a sequence diagram instead to rearrange messages as needed before switching back to the collaboration diagram. The document includes exercises for the reader to practice these skills by creating sample collaboration and sequence diagrams.
This document provides an introduction to sequence diagrams in Rational Rose 98i. It outlines how to create a sequence diagram, assign objects to classes, add and manipulate messages between objects, and create scripts and collaboration diagrams based on the sequence diagram. The objectives are to learn how to create a sequence diagram, assign objects, map messages to operations, create scripts, and generate a collaboration diagram from the sequence diagram.
This document provides an introduction to class diagrams in Rational Rose 98i. It covers how to create classes, add attributes and operations, define relationships between classes, and use packages to organize classes. The key elements of a class diagram - classes, interfaces, packages and relationships - are described. Guidelines are provided for documenting classes, applying stereotypes, and setting attribute and operation visibility. The document concludes with exercises for creating example class diagrams.
The document introduces use case diagrams, which show the functionality of a system and how it interacts with external actors. It discusses creating actors and use cases, documenting use cases, and relationships between use cases and actors. The exercises at the end instruct the reader to create a use case diagram based on example pictures and documentation.
Rational Rose 98i is a UML modeling tool that supports different views like use case, interaction, logical, component and deployment views. It allows creating models with packages, classes, use cases and other elements. The user interface consists of toolbars, browser, documentation window and diagram windows. Pathmaps and options can be configured for team development.
This document provides an introduction and outline for a course on using Rational Rose 98i Version 5.2. The course is intended for anyone needing to learn the capabilities of Rational Rose. Upon completion, participants will be able to use Rational Rose to document software projects, understand team development strategies, create scripts using RoseScript, and generate reports. The course outline covers creating various UML diagrams like use case diagrams, class diagrams, sequence diagrams, collaboration diagrams, state diagrams, activity diagrams, component diagrams, and deployment diagrams. It also covers team development and scripting.
1. Công cụ và môi trường phát triển phần mềm
Giới thiệu
về hướng đối tượng
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 1
2. Mục tiêu
w Tìm hiểu các nguyên tắc cơ bản của hướng đối tượng (object
orientation – OO)
w Tìm hiểu các khái niệm cơ bản và các thuật ngữ của hướng đối
tượng kết hợp với hệ thống ký hiệu của UML
w Đánh giá chính xác sức mạnh của OO
w Tìm hiểu một số cơ chế mô hình hoá cơ bản của UML
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 2
3. Giới thiệu về Hướng đối tượng: Các chủ đề
w Các nguyên tắc cơ bản của OO
w Các khái niệm cơ bản của OO
w Sức mạnh của OO
w Các cơ chế mô hình hoá cơ bản của UML
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 3
4. Khoa CNTT - ĐHKHTN
Giới thiệu về hướng đối tượng
Trừu tượng hóa
Abstraction
Tính đóng gói
Encapsulation
4
Các nguyên tắc cơ bản của OO
Tính đơn thể
Hướng đối tượng
Modularity
Tính phân cấp
Hierarchy
5. Thế nào là trừu tượng hóa?
Người bán hàng
Sản phẩm
Khách hàng
Quản lý được độ phức tạp
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 5
6. Đóng gói (Encapsulation) là gì?
w Che dấu cài đặt bên trong với clients
§ Clients phụ thuộc vào interface
Tăng tính mềm dẻo
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 6
7. Tính đơn thể là gì?
w Phân chia nhỏ một vấn đề phức tạp thành nhiều
phần nhỏ, đơn giản hơn quản lý được
Nhận
đơn đặt hàng
Hệ thống xử lý đơn
đặt hàng Thực hiện
đơn đặt hàng
Tính tiền
Quản lý được độ phức tạp
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 7
8. Sự phân cấp (Hierarchy) là gì?
Tài sản
w Mức độ trừu tượng hoá
Tăng mức độ trừu
tượng
Tài khoản Chứng khoán Bất động sản
Tài khoản Tài khoản Cổ phiếu Trái phiếu
Tiết kiệm Thanh toán
Giảm mức độ trừu
tượng
Các phần tử trên cùng một mức phải
có cùng mức độ trừu tượng
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 8
9. Giới thiệu về Hướng đối tượng: Các chủ đề
w Các nguyên tắc cơ bản của OO
w Các khái niệm cơ bản của OO
w Sức mạnh của OO
w Các cơ chế mô hình hoá cơ bản của UML
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 9
10. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 10
11. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 11
12. Object là gì?
w Một cách không hình thức, một đối tượng biểu diễn một
thực thể, dạng vật lý, khái niệm, hoặc phần mềm
§ Thực thể vật lý
Truck
§ Thực thể khái niệm
Chemical Process
§ Thực thể phần mềm
Linked List
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 12
13. Một định nghĩa hiệu quả hơn
w Một đối tượng là một khái niệm, sự trừu tượng, hoặc một
vật với giới hạn rõ ràng và có ý nghĩa với một ứng dụng cụ
thể
w Một đối tượng có:
§ Trạng thái
§ Hành vi
§ Định danh (Identity)
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 13
14. Biểu diễn đối tượng
w Một đối tượng được biểu diễn bởi một hình chữ nhật với
tên được gạch dưới
: Professor
a + b = 10
ProfessorClark
Chỉ có tên Class
Professor Clark
ProfessorClark :
Professor Chỉ có tên đối tượng
Tên class và tên đối tượng
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 14
15. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 15
16. Class là gì?
w Class là mô tả của một nhóm đối tượng có chung các thuộc
tính (attributes), hành vi (operations), các mối quan hệ và ngữ
nghĩa
§ Một đối tượng là một thể hiện của class
w Một class là sự trừu tượng mà trong đó:
§ Nhấn mạnh các tính chất quan trọng
§ Bỏ qua các tính chất khác
Nguyên tắc OO: Trừu tượng hóa
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 16
17. Ví dụ về Class
Class
Course
Properties Behavior
Tên Thêm một sinh viên
Địa điểm Huỷ một sinh viên
a + b = 10
Thời gian Lấy danh sách giáo sư
Số tín chỉ Xác định hết chỗ chưa
Giờ bắt đầu
Giờ kết thúc
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 17
18. Biểu diễn Class
w Một class biểu diễn bằng một hình chữ nhật gồm ba phần
a + b = 10
Professor
Professor Clark
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 18
19. Các phần trong một Class
w Một class bao gồm ba phần
§ Phần đầu chứa tên class
§ Phần thứ hai cho thấy cấu trúc của lớp (attributes)
§ Phần thứ ba cho thấy các hành vi của lớp (operations)
Tên class Professor
name
Attributes empID
Operations create( )
save( )
delete( )
change( )
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 19
20. Các lớp đối tượng
w Bạn nhìn thấy có bao nhiêu class?
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 20
21. Quan hệ giữa class và đối tượng
w Một class là một định nghĩa trừu tượng của một đối tượng
§ Nó định nghĩa cấu trúc và hành vi của mỗi đối tượng trong
lớp
§ Nó được dùng như khuôn mẫu để tạo đối tượng
w Các đối tượng được nhóm thành các class
Objects Class
Professor
Professor Smith Professor Mellon
Professor Jones
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 21
22. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 22
23. Thuộc tính (Attribute) là gì?
Object
Class
Attribute Attribute Value
:CourseOffering
number = 101
startTime = 900
CourseOffering endTime = 1100
number
startTime
endTime :CourseOffering
number = 104
startTime = 1300
endTime = 1500
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 23
24. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 24
25. Hành vi (Operation) là gì?
CourseOffering
Class
addStudent
deleteStudent
getStartTime
Operation getEndTime
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 25
26. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 26
27. Polymorphism là gì?
w Khả năng che dấu nhiều cài đặt khác nhau bên dưới một giao
diện duy nhất
Nhà SX B
Nhà SX A Nhà SX C
Nguyên tắc OO:
Đóng gói
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 27
28. Interface là gì?
w Interface hình thức hoá polymorphism
w Interface hỗ trợ kiến trúc “plug-and-play”
Tube
<<interface>>
Shape
Pyramid
Draw
Move
Scale
Rotate Cube
Quan hệ Realization
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 28
29. Biểu diễn Interface
Tube
Biểu diễn rút gọn
Pyramid
Shape Cube
Biểu diễn chính tắc Tube
Class/Stereotype) <<interface>>
Shape
Pyramid
Draw
Move
Scale
Rotate Cube
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 29
30. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 30
31. Component là gì?
w Một phần không tầm thường của hệ thống, gần như độc lập và
có thể thay thế được, giữ một chức năng rõ ràng trong hệ thống
w Một component có thể là
§ Một source code component
§ Một run time components hoặc Nguyên tắc OO:
§ Một executable component Đóng gói
Source File <<EXE>> <<DLL>>
Name Executable Component
Name Component Name
Interface
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 31
32. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 32
33. Package là gì?
w Một package là một cơ chế để tổ chức các phần tử vào thành
các nhóm
w Một phần tử trong mô hình có thể chứa các phần tử khác
Nguyên tắc OO:
Package Name Tính đơn thể
w Dùng để
§ Tổ chức mô hình đang phát triển
§ Một đơn vị trong quản trị cấu hình
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 33
34. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 34
35. Subsystem là gì?
w Tổ hợp của một package (có thể chứa các phần tử khác trong
mô hình) và một class (có hành vi)
w Hiện thực hoá một hoặc nhiều interface định nghĩa cho hành vi
của nó
Realization
Subsystem
<<subsystem>>
Interface Subsystem Name
Interface
Nguyên tắc OO: Đóng gói và Tính đơn thể
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 35
36. Subsystem và Component
w Component là thể hiện ở mức vật lý của một khái niệm trừu
tượng trong thiết kế
w Subsystem có thể dùng để biểu diễn các component trong thiết
kế
Design Model Implementation Model
<<subsystem>> Component
Component Name Name
Component Component
Interface Interface
Nguyên tắc OO: Đóng gói và Tính đơn thể
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 36
37. Các khái niệm cơ bản của Hướng đối tượng
w Object
w Class
w Attribute
w Operation
w Interface (Polymorphism)
w Component
w Package
w Subsystem
w Relationships
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 37
38. Các mối quan hệ
w Association (Kết hợp)
§ Aggregation (Thu nạp)
§ Composition (Cấu thành)
w Dependency (Phụ thuộc)
w Generalization (Tổng quát hóa)
w Realization (Hiện thực hoá)
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 38
39. Mối quan hệ: Association
w Mô hình hoá một liên kết ngữ nghĩa giữa các class
Teân Association
Professor Daïy cho University
Association
Tên Role
Class University
Professor
Employee Employer
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 39
40. Mối quan hệ: Aggregation
w Một dạng đặc biệt của association mô hình hoá mối quan hệ
toàn thể-bộ phận giữa một thực thể và các bộ phận của nó
Whole Part
Student Schedule
Aggregation
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 40
41. Mối quan hệ: Composition
w Một dạng aggregation có tính sở hữu cao và cùng chu kỳ sống
§ Các bộ phận không thể sống lâu hơn thực thể
Whole Part
Student Schedule
Aggregation
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 41
42. Association: Bản số và Chiều
w Bản số xác định số đối tượng tham gia vào một mối quan hệ
§ Số các thể hiện của một class quan hệ với MỘT thể hiện
của một class khác
§ Được chỉ ra ở mỗi đầu của quan hệ association
w Association và aggregation mặc định là hai chiều, nhưng người
ta thường giới hạn theo một chiều
§ Mũi tên được thêm vào để chỉ chiều của mối quan hệ
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 42
43. Association: Bản số
w Không xác định
w Chỉ một 1
w Không hoặc nhiều 0..*
*
w Một hoặc nhiều 1..*
w Không hoặc một 0..1
w Khoảng được chỉ định 2..4
w Các khoảng không liên tục 2, 4..6
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 43
44. Ví dụ: Bản số và Chiều
Multiplicity
Student 1 0..* Schedule
Navigation
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 44
45. Mối quan hệ: Dependency
w Quan hệ giữa hai phần tử trong mô hình mà thay đổi ở phần tử
này có thể gây ra thay đổi ở phần tử kia
w Quan hệ “sử dụng”, không cấu trúc
Client Supplier Component
Class
Package Client Supplier
Dependency
relationship
ClientPackage SupplierPackage
Dependency
relationship
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 45
46. Mối quan hệ: Generalization
w Quan hệ giữa các class trong đó một lớp chia sẻ cấu trúc
và/hoặc hành vi của một hoặc nhiều class khác
w Xác định một sự phân cấp các mức độ trừu tượng trong đó một
subclass kế thừa từ một hoặc nhiều superclass
§ Đơn kế thừa
§ Đa kế thừa
w Generalization là quan hệ “là một dạng của”
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 46
47. Ví dụ: Đơn kế thừa
w Một class kế thừa từ một class khác
Tổ tiên
Account
balance
name
Superclass (cha) number
Withdraw()
CreateStatement()
Generalization
Relationship
Checking Savings
Subclasses Withdraw() GetInterest()
Withdraw()
Hậu duệ
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 47
48. Ví dụ: Đa kế thừa
w Một class kế thừa từ nhiều class khác
FlyingThing Animal
Đa kê thừa
Airplane Helicopter Bird Wolf Horse
Chỉ sử dụng đa kế thừa khi thật cần, và luôn
phải cẩn thận !
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 48
49. Cái gì được kế thừa?
w Một subclass kế thừa các thuộc tính, hành vi và các mối quan
hệ từ cha nó
w Một subclass có thể:
§ Bổ sung thuộc tính, hành vi và các mối quan hệ
§ Định nghĩa lại các hành vi (nên cẩn thận!)
w Các thuộc tính, hành vi và các mối quan hệ chung được đặt ở
mức cao nhất có thể trong cấu trúc phân cấp
Sự kế thừa làm nổi bật các điểm tương đồng giữa các class
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 49
50. Ví dụ: Cái gì được kế thừa
GroundVehicle
owner Person
Superclass weight
(cha) licenseNumber 0..* 1
register( )
generalization
Car Truck Trailer
Subclass size tonnage
getTax( )
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 50
51. Mối quan hệ: Realization
w Một classifier đóng vai trò một hợp đồng mà một classifier khác
đồng ý thực hiện
w Xuất hiện giữa:
§ Các Interface và các classifier hiện thực chúng
Class Component
Subsystem
Interface Interface
Interface
Dạng tắt
§ Các Use case và các collaboration hiện thực chúng
Dạng chính tắc
Use Case Use-Case Realization
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 51
52. Giới thiệu về Hướng đối tượng: Các chủ đề
w Các nguyên tắc cơ bản của OO
w Các khái niệm cơ bản của OO
w Sức mạnh của OO
w Các cơ chế mô hình hoá cơ bản của UML
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 52
53. Sức mạnh của Hướng đối tượng
w Một mô hình chung
w Có tính dễ dùng lại
w Mô hình phản ánh chính xác thế giơi thực
§ Mô tả chính xác hơn các tập dữ liệu và các xử lý
§ Được phân rã dựa trên các phân chia tự nhiên
§ Dễ hiểu và dễ bảo trì
w Tính ổn định
§ Một thay đổi nhỏ trong yêu cầu không gây ra sự thay đổi lớn
trong hệ thống đang phát triển
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 53
54. Một ví dụ đơn giản: Sales Order System
Đặt hàng
Sản xuất
Vận chuyển bằng
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 54
55. Class Diagram của ví dụ “bán hàng”
Sale
seller buyer item sold shipping mechanism
Salesperson Customer Product Vehicle
Corporate Individual Truck Train
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 55
56. Hiệu ứng của sự thay đổi yêu cầu
Giả sử bạn cần phương
tiện vận chuyển mới ...
Sale
seller buyer item sold shipping mechanism
Salesperson Customer Product Vehicle
Corporate Individual Truck Train Airplane
Việc thay đổi liên quan đến việc thêm 1 subclas mới
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 56
57. Giới thiệu về Hướng Đối Tượng: Các chủ đề
w Các nguyên tắc cơ bản của OO
w Các khái niệm cơ bản của OO
w Sức mạnh của OO
w Các cơ chế mô hình hoá cơ bản của UML
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 57
58. Các khuôn mẫu (Stereotype)
w Phân lớp và mở rộng các phần tử trong hệ thống ký hiệu UML
w Định nghĩa một phần tử của mô hình mới dựa trên một phần tử
khác
w Có thể áp dụng cho mọi phần tử mô hình
w Được biểu diễn với tên đặt trong dấu << >> hoặc bằng các icon
khác
<<boundary>>
MyBoundaryClass
MyBoundaryClass
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 58
59. Ví dụ: Stereotype
<<boundary>>
<<boundary>>
<<trace>>
DesignClass
<<Processor>>
Processor #1 Processor #1
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 59
60. Các ghi chú (note)
w Có thể đặt ghi chú cho mọi phần tử UML
w Ghi chú dùng để thêm thông tin cho các lược đồ
w Nó là hình chữ nhật bị bẻ góc
w Ghi chú có thể móc nối với một phần tử bằng một đường đứt
nét
There can be up to one
MaintainScheduleForm per
MaintainScheduleForm user session.
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 60
61. Các giá trị đính (Tagged Values)
w Là sự mở rộng của các thuộc tính hoặc của các phần tử UML
w Là một số thuộc tính được định nghĩa sẵn bởi UML
§ Persistence
§ Location (chẳng hạn client, server)
w Là các thuộc tính có thể được tạo bởi các nhà mô hình hoá
UML phục vụ cho mục đích bất kỳ
PersistentClass
{persistence} anObject : ClassA
{location=server}
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 61
62. Các ràng buộc (Constraints)
w Hỗ trợ việc thêm các luật mới hoặc hiệu chỉnh các luật đang tồn
tại
Member 1
Professor Department
1..*
{subset}
Department Head
1 1
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 62
63. Câu hỏi ôn tập
w Bốn nguyên tắc cơ bản của OO là gì ? Mô tả ngắn gọn về mối
nguyên tắc.
w Đối tượng là gì ? Class là gì ? Những điểm khác nhau giữa
chúng ?
w Thuộc tính (Attribute) là gì ?
w Hành vi (Operation) là gì ?
w Interface là gì ? Polymorphism là gì ?
w Component là gì ?
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 63
64. Câu hỏi ôn tập (tt)
w Package là gì?
w Subsystem là gì ? Nó có quan hệ như thế nào với Component?
Nó có quan hệ như thế nào với package? Nó có quan hệ như
thế nào với class?
w Tên của 4 quan hệ UML cơ bản ? Mô tả từng quan hệ.
w Mô tả sức mạnh của OO.
w Cho biết tên và mô tác một số cơ chế tổng quát trong UML.
w Stereotype là gì? Cho biết tên của một số stereotype dùng
chung.
Giới thiệu về hướng đối tượng
Khoa CNTT - ĐHKHTN 64