(Class_Stereotype)_第1页
(Class_Stereotype)_第2页
(Class_Stereotype)_第3页
(Class_Stereotype)_第4页
(Class_Stereotype)_第5页
已阅读5页,还剩36页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Object Oriented Analysis and Design Using the UMLIntroduction to Object Orientation(abbreviated!)Objectives: Introduction to Object OrientationUnderstand the basic principles of object orientation Understand the basic concepts and terms of object orientation and the associated UML notationAppreciate

2、 the strengths of object orientation Understand some basic UML modeling mechanismsObject OrientationEncapsulationAbstractionHierarchyModularity1. Basic Principles of Object OrientationKnow This.SalespersonNot saying which salesperson just a salesperson in general!CustomerProductManages ComplexityWha

3、t is Abstraction?Improves ResiliencyWhat is Encapsulation?Hide implementation from clientsClients depend on interface only!Clients do not need to know how the server operates or provides the services!How does an object encapsulate?What does it encapsulate?DISCUSS!Order Processing SystemBillingOrderE

4、ntryOrderFulfillmentManages 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 of abstrac

5、tionWhat is Hierarchy? Levels of abstraction2. Basic Concepts of Object OrientationObjectClassAttributeOperationInterface (Polymorphism)ComponentPackageSubsystemRelationshipsA More Formal Definition An object is a concept, abstraction, or thing with sharp boundaries and meaning for an application An

6、 object is something that has:StateBehaviorIdentityKnow This.: ProfessorProfessor Clarka + b = 10ProfessorClark : ProfessorProfessorClarkClass Name OnlyObject Name OnlyClass and Object Name(stay tuned for classes)Representing Objects the beginningsAn object is represented as a rectangle with underli

7、ned name (no class name shown here)(unnamed object)OO Principle: AbstractionWhat is a Class? A class is a description of a group of objects with common properties (attributes), behavior (operations), relationships, and semantics A class is an abstraction of objects.An object is an instance of a clas

8、sProfessorProfessor Clarka + b = 10Representing ClassesA class is represented using a compartmented rectangle (note: no underlining)ProfessornameempIDcreate( )save( )delete( )change( )Class NameAttributesOperationsClass Compartments a bit more developmentA class is comprised of three sectionsThe fir

9、st section contains the class nameThe second section shows the structure (attributes)The third section shows the behavior (operations)ObjectsClassProfessor SmithProfessor JonesProfessor MellonProfessorThe Relationship Between Classes and ObjectsA class is an abstract definition of an objectIt define

10、s the structure and behavior of each object in the classIt serves as a template for creating objects :CourseOfferingnumber = 101startTime = 900endTime = 1100:CourseOfferingnumber = 104startTime = 1300endTime = 1500CourseOfferingnumberstartTime endTimeClassAttributeObjectSpecific attribute valuesfor

11、different objectsWhat is an Attribute?CourseOfferingaddStudent deleteStudentgetStartTimegetEndTimeClassOperationWhat is an Operation? (very general form here)Really need to show more, but here, this is sufficient.Source FileNameExecutableNameOO Principle:EncapsulationWhat is a Component?A non-trivia

12、l, 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 component orAn executable componentComponentNameComponent InterfacePackage NameOO Principle:ModularityWhat is a Pa

13、ckage?A package is a general purpose mechanism for organizing like elements into groupsA model element which can contain other model elementsThink: in the Java API, similar classes are found in packages that we may import, etc. UsesOrganize the model under developmentA unit of configuration manageme

14、ntThink: Math class. (contains math classes such as cos() )Know ThisOO Principles: Encapsulation and ModularitySubsystem NameInterfaceInterfaceRealizationSubsystem(stay tuned for realization relationship)What is a Subsystem?A combination of a package (contains other model elements) and a class (has

15、behaviors)A subsystem: realizes one or more interfaces which define its behaviorInterface is an abstract class. Subsystems implement (realize) the interface(s)Know This.RelationshipsAssociationAggregationCompositionDependencyGeneralizationRealizationProfessorUniversityWorks forClassAssociationAssoci

16、ation NameProfessorUniversityEmployerEmployeeRole Names Relationships: AssociationModels a semantic connection among classesStudentScheduleWholeAggregation sometimes called simple aggregation.This is sometimes called a has_a relationshipPartRelationships: Aggregation (simple aggregate)A special form

17、 of association that models a whole-part relationship between an aggregate (the whole) and its partsKnow ThisStudentScheduleWholeAggregationThis one is called composition.PartRelationships: CompositionA form of aggregation with strong ownership and coincident lifetimesThe parts cannot survive the wh

18、ole/aggregate Know ThisAssociation: Multiplicity and NavigationMultiplicity defines how many objects participate in a relationshipThe number of instances (that is, objects) of one class related to ONE instance of another class (examples ahead)Specified for each end of the associationAssociations and

19、 aggregations are bi-directional by default, but it is often 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 o

20、r moreZero or oneSpecified rangeMultiple, disjoint ranges2, 4.6StudentSchedule10.*MultiplicityNavigationExample: Multiplicity and NavigationNote: A student has zero or more schedules. (Multiplicity)Note: Aggregation: has_a (whole-part relationship). ClientSupplierPackageClientPackageSupplierPackageC

21、lientSupplierClassDependency relationshipDependency relationshipComponent Relationships: DependencyA relationship between two model elements where a change in one may cause a change in the otherNon-structural, “using” (or “communicates”) relationship(non-structural: no numbers of one kind related to

22、 another kind)Can actually say the Client uses the Supplier.Know This Relationships: 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 superclasses Ge

23、neralization is a “is-a-kind of” relationship, or simply, “is_a” relationship.AccountbalancenamenumberWithdraw()CreateStatement()CheckingWithdraw()SavingsGetInterest()Withdraw()Superclass (parent)SubclassesGeneralization RelationshipSubclasses inherit both attributes and methods from base (parent) c

24、lass.AncestorDescendentsExample: Single InheritanceOne class inherits from anotherAirplaneHelicopterWolfHorseFlyingThingAnimalBirdmultipleinheritanceUse multiple inheritance only when needed, and always with caution !Example: Multiple InheritanceA class can inherit from several other classesInherita

25、nce leverages the similarities among classesWhat Gets Inherited?A subclass inherits its parents attributes, operations, and relationshipsA subclass may add:additional attributes, operations, relationshipsRedefine inherited operations (use caution!)Common attributes, operations, and/or relationships

26、are shown at the highest applicable level in the hierarchyTrucktonnageGroundVehicleweightlicenseNumberCarownerregister( )getTax( )Person0.*Trailer1Superclass (parent)SubclassgeneralizationsizeExample: What Gets Inherited (note form of arrow)What about a register() in Car? Use CaseUse-Case Realizatio

27、nElided formSubsystemInterfaceCanonical formRelationships: Realization (note form of arrow)One classifier serves as the contract that the other classifier agrees to carry outFound between: Interfaces and the classifiers that realize themUML Connection Lines Important. Know these.Note the UML line ty

28、pes - important:Dashed, arrowhead dependencyDashed, open triangle realizesSolid line, open triangle inheritance (is_a)Solid line, arrowhead uses / communicates withSolid line, diamond aggregates (has_a)Introduction to Object Orientation TopicsBasic Principles of Object OrientationBasic Concepts of O

29、bject OrientationStrengths of Object OrientationGeneral UML Modeling MechanismsMyBoundaryClassMyBoundaryClass4. StereotypesClassify/extend UML notational elementsDefine a new model element in terms of another model elementMay be applied to all modeling elementsRepresented with name in guillemets or

30、as a different icon There can be up to one MaintainScheduleForm per user session.MaintainScheduleFormNotesA Note can be added to any UML elementThe class diagram is the one most often extendedNotes may be added to add more info to diagram It is a dog eared rectangle The note may be anchored to an el

31、ement with a dashed linePersistentClasspersistenceanObject : ClassAlocation=serverTagged ValuesExtensions of the properties, or specific attributes, of a UML elementSome properties are defined by UMLPersistenceLocation (e.g., client, server)Properties can be created by UML modelers for any purposeProfessorDepartmentMemberDepartment Headsubset1.

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论