版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Introduction to Object OrientationObjectives: Introduction to Object OrientationUnderstand the basic principles of object orientation Understand the basic concepts and terms of object orientation and the associated UML notationAppreciate the strengths of object orientation Understand some basic UML
2、modeling mechanismsIntroduction to Object Orientation TopicsBasic Principles of Object OrientationBasic Concepts of Object OrientationStrengths of Object OrientationGeneral UML Modeling MechanismsObject OrientationEncapsulationAbstractionHierarchyModularityBasic Principles of Object OrientationSales
3、personNot saying Which salesperson just a salesperson in general!CustomerProductManages ComplexityWhat is Abstraction?Improves ResiliencyWhat is Encapsulation?Hide implementation from clientsClients depend on interfaceHow does an object encapsulate?What does it encapsulate?Order Processing SystemBil
4、lingOrderEntryOrderFulfillmentManages ComplexityWhat is Modularity?The breaking up of something complex into manageable piecesDecreasing abstractionIncreasing abstractionAssetRealEstateSavingsBankAccountCheckingStockSecurityBondElements at the same level of the hierarchy should be at the same level
5、of abstractionWhat is Hierarchy? Levels of abstractionIntroduction to Object Orientation TopicsBasic Principles of Object OrientationBasic Concepts of Object OrientationStrengths of Object OrientationGeneral UML Modeling MechanismsBasic Concepts of Object OrientationObjectClassAttributeOperationInte
6、rface (Polymorphism)ComponentPackageSubsystemRelationshipsBasic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystemRelationshipsTruckChemical ProcessLinked ListWhat is an Object?Informally, an object represents an entity, either physical, conc
7、eptual, or softwarePhysical entityConceptual entitySoftware entityA More Formal Definition An object is a concept, abstraction, or thing with sharp boundaries and meaning for an application An object is something that has:StateBehaviorIdentity: ProfessorProfessor Clarka + b = 10ProfessorClark : Prof
8、essorProfessorClarkClass Name OnlyObject Name OnlyClass and Object Name(stay tuned for classes)Representing ObjectsAn object is represented as rectangles with underlined namesBasic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystemRelationshi
9、psOO Principle: AbstractionWhat is a Class?A class is a description of a group of objects with common properties (attributes), behavior (operations), relationships, and semanticsAn object is an instance of a classA class is an abstraction in that it:Emphasizes relevant characteristicsSuppresses othe
10、r characteristicsa + b = 10ClassCoursePropertiesNameLocationDays offeredCredit hoursStart timeEnd timeBehaviorAdd a studentDelete a studentGet course rosterDetermine if it is fullSample ClassProfessorProfessor Clarka + b = 10Representing ClassesA class is represented using a compartmented rectangleP
11、rofessornameempIDcreate( )save( )delete( )change( )Class NameAttributesOperationsClass CompartmentsA class is comprised of three sectionsThe first section contains the class nameThe second section shows the structure (attributes)The third section shows the behavior (operations)Classes of ObjectsHow
12、many classes do you see?ObjectsClassProfessor SmithProfessor JonesProfessor MellonProfessorThe Relationship Between Classes and ObjectsA class is an abstract definition of an objectIt defines the structure and behavior of each object in the classIt serves as a template for creating objects Objects a
13、re grouped into classesBasic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystemRelationships:CourseOfferingnumber = 101startTime = 900endTime = 1100:CourseOfferingnumber = 104startTime = 1300endTime = 1500CourseOfferingnumberstartTime endTime
14、ClassAttributeObjectAttribute ValueWhat is an Attribute?Basic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystem RelationshipsCourseOfferingaddStudent deleteStudentgetStartTimegetEndTimeClassOperationWhat is an Operation?Basic Concepts of Obj
15、ect OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystem RelationshipsManufacturer AManufacturer BManufacturer COO Principle:EncapsulationWhat is Polymorphism?The ability to hide many different implementations behind a single interfaceTubePyramidCubeShapeDrawMove
16、ScaleRotateRealization relationship(stay tuned for realization relationships)What is an Interface?Interfaces formalize polymorphismInterfaces support “plug-and-play architecturesTubePyramidCubeShapeDrawMoveScaleRotateTubePyramidCubeShapeElided/Iconic Representation(“lollipop)Canonical (Class/Stereot
17、ype) Representation(stay tuned for realization relationships)Interface RepresentationsBasic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystem RelationshipsSource FileNameExecutableNameOO Principle:EncapsulationWhat is a Component?A non-trivi
18、al, nearly independent, and replaceable part of a system that fulfills a clear function in the context of a well-defined architecture A component may be A source code componentA run time components orAn executable componentComponentNameComponent InterfaceBasic Concepts of Object OrientationObjectCla
19、ssAttributeOperationInterface (Polymorphism)ComponentPackageSubsystem RelationshipsPackage NameOO Principle:ModularityWhat is a Package?A package is a general purpose mechanism for organizing elements into groupsA model element which can contain other model elementsUsesOrganize the model under devel
20、opmentA unit of configuration managementBasic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystem RelationshipsOO Principles: Encapsulation and ModularitySubsystem NameInterfaceInterfaceRealizationSubsystem(stay tuned for realization relations
21、hip)What is a Subsystem?A combination of a package (can contain other model elements) and a class (has behavior)Realizes one or more interfaces which define its behaviorComponentNameDesign ModelImplementation ModelComponent NameComponent InterfaceComponent InterfaceOO Principles: Encapsulation and M
22、odularitySubsystems and ComponentsComponents are the physical realization of an abstraction in the designSubsystems can be used to represent the component in the designBasic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystem RelationshipsRela
23、tionshipsAssociationAggregationCompositionDependencyGeneralizationRealizationProfessorUniversityWorks forClassAssociationAssociation NameProfessorUniversityEmployerEmployeeRole NamesRelationships: AssociationModels a semantic connection among classesStudentScheduleWholeAggregationPartRelationships:
24、AggregationA special form of association that models a whole-part relationship between an aggregate (the whole) and its partsStudentScheduleWholeAggregationPartRelationships: CompositionA form of aggregation with strong ownership and coincident lifetimesThe parts cannot survive the whole/aggregate A
25、ssociation: Multiplicity and NavigationMultiplicity defines how many objects participate in a relationshipsThe number of instances of one class related to ONE instance of the other classSpecified for each end of the associationAssociations and aggregations are bi-directional by default, but it is of
26、ten desirable to restrict navigation to one directionIf navigation is restricted, an arrowhead is added to indicate the direction of the navigationAssociation: Multiplicity2.40.11.*0.*1*UnspecifiedExactly oneZero or more (many, unlimited)One or moreZero or oneSpecified rangeMultiple, disjoint ranges
27、2, 4.6StudentSchedule10.*MultiplicityNavigationExample: Multiplicity and NavigationClientSupplierPackageClientPackageSupplierPackageClientSupplierClassDependency relationshipDependency relationshipComponentRelationships: DependencyA relationship between two model elements where a change in one may c
28、ause a change in the otherNon-structural, “using relationshipRelationships: GeneralizationA relationship among classes where one class shares the structure and/or behavior of one or more classesDefines a hierarchy of abstractions in which a subclass inherits from one or more superclassesSingle inher
29、itanceMultiple inheritanceGeneralization is an “is-a-kind of relationshipAccountbalancenamenumberWithdraw()CreateStatement()CheckingWithdraw()SavingsGetInterest()Withdraw()Superclass (parent)SubclassesGeneralization RelationshipAncestorDescendentsExample: Single InheritanceOne class inherits from an
30、otherAirplaneHelicopterWolfHorseFlyingThingAnimalBirdmultipleinheritanceUse multiple inheritance only when needed, and always with caution !Example: Multiple InheritanceA class can inherit from several other classesInheritance leverages the similarities among classesWhat Gets Inherited?A subclass in
31、herits its parents attributes, operations, and relationshipsA subclass may:Add additional attributes, operations, relationshipsRedefine inherited operations (use caution!)Common attributes, operations, and/or relationships are shown at the highest applicable level in the hierarchyTrucktonnageGroundV
32、ehicleweightlicenseNumberCarownerregister( )getTax( )Person0.*Trailer1Superclass (parent)SubclassgeneralizationsizeExample: What Gets InheritedComponentInterfaceUse CaseUse-Case RealizationElided formClassInterfaceSubsystemInterfaceCanonical formRelationships: RealizationOne classifier serves as the
33、 contract that the other classifier agrees to carry outFound between:Interfaces and the classifiers that realize themUse cases and the collaborations that realize themInBasic Principles of Object OrientationBasic Concepts of Object OrientationStrengths of Object OrientationGeneral UML Modeling Mecha
34、nismsStrengths of Object OrientationA single paradigmFacilitates architectural and code reuseModels more closely reflect the real worldMore accurately describe corporate data and processesDecomposed based on natural partitioningEasier to understand and maintainStabilityA small change in requirements
35、 does not mean massive changes in the system under developmentClass Diagram for the Sales ExampleSalespersonProductSaleCorporateCustomerIndividualTruckVehicleTrainsellerbuyeritem soldshipping mechanismEffect of Requirements ChangeSuppose you need a new type of shipping vehicle .SalespersonProductSal
36、eCorporateCustomerIndividualTruckVehicleTrainsellerbuyeritem soldshipping mechanismChange involves adding a new subclassAirplaneIntroduction to Object Orientation TopicsBasic Principles of Object OrientationBasic Concepts of Object OrientationStrengths of Object OrientationGeneral UML Modeling Mecha
37、nismsMyBoundaryClassMyBoundaryClassStereotypesClassify and extend the UML notational elementsDefine a new model element in terms of another model elementMay be applied to all modeling elementsRepresented with name in guillemets or as a different icon Processor #1DesignClassProcessor #1Example: Stere
38、otypesSample boundary class (stereotype)Stereotype of dependency relationStereotype of These create new symbols using accustomed graphics.There can be up to one MaintainScheduleForm per user session.MaintainScheduleFormNotesA note can be added to any UML elementNotes may be added to add more information to the diagram It is a dog eared rectangle The note may be anchored to an element with a dashed linePersistentClasspersistenceanObject : ClassAlocation=serverTagged
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026学年四年级上册小学语文同步阶段测试卷(统编版)
- 2026年初中美术试卷培训试卷
- 钎焊材料问答题目及答案
- 思想动态调查报告2026(3篇)
- 餐饮合作合同协议书餐厅入股合作协议书(范本)
- 孕酮测定测验试题及答案
- 河科大机械制造基础习题及答案01名词解释
- 文献检索资格证试题及答案
- 内部财务审计标准
- 2026中国智能窗帘传感器行业市场供需分析及投资评估规划分析研究报告
- 2025年新《治安管理处罚法》知识考试题库及答案
- 2025年广州市番禺区大龙街社区卫生服务中心公开招考编外人员备考题库及完整答案详解一套
- 售前工程师转正述职报告
- 安全阀拆装培训课件
- 河南省养老类建筑消防设计技术要点2025
- 海天考研协议书
- 《电镀工艺原理与应用》课件
- 浙江省SBS改性沥青混合料应用技术规程
- DL/T5315-2014水工混凝土建筑物修补加固技术规程(完整)
- 项目财务策划
- 《责任心与执行力》课件
评论
0/150
提交评论