object oriented analysis and design using uml

Download Object Oriented Analysis and Design Using UML

If you can't read please download the document

Upload: jamar

Post on 06-Jan-2016

106 views

Category:

Documents


13 download

DESCRIPTION

Object Oriented Analysis and Design Using UML. Evolution of Object-Oriented Development Methods. Mid to late 1980s Object-Oriented Languages (esp. C++) were very much in vogue However, there was little guidance on how to divide a problem into OO classes. UML. Unified Modeling Language - PowerPoint PPT Presentation

TRANSCRIPT

  • Object OrientedAnalysis and Design UsingUML

  • Evolution of Object-Oriented Development MethodsMid to late 1980sObject-Oriented Languages (esp. C++) were very much in vogueHowever, there was little guidance on how to divide a problem into OO classes.

  • UMLUnified Modeling LanguageIn early 90s, there were many competing graphical notations all used for OOA.Three of the major players got together in Boochs company

  • Rational Software CorporationBooch, Rumbaugh, JacobsonMerged their ideas to produceUML (public domain)Associated tools (mainly Rational Rose)Rational Software Process (public domain)Acquired other companies (Purify, Quantify, )

  • Uses for UMLOOAA visual language for, in the problem domain,capturing knowledge about a subjectexpressing knowledge for the purposes of communication

  • OODA visual language for, in the solution space,capturing design ideascommunicating design ideas

    Related, but distinct usagesMust supplement both with written explanations

  • UMLHas its warts Good enough when augmented by written explanationCover only the most useful subset of UMLMainly class/object/use case/sequence charts.

  • Books on UMLYou must acquire reference materials on UMLSome of these lecture materials prepared fromUML In A Nutshell (OReilly) by Sinan Si AlhirAlsoThe Unified Modeling Language User GuideBooch et. al.AlsoReference materials off the Web

  • Object Modeling books:Object Oriented Analysis and DesignBooch et.al.Designing Object-Oriented SoftwareWirfs-Brock et. al.Object-Oriented Modeling and DesignRumbaugh et. al.Object-Oriented AnalysisCoad and Yourdon

  • OMG-endorsed standard (Object Management Group)UML Semantics Documentinside-viewspecifies semantics of constructsUML Notation Guideoutside-viewspecifies notation for expressing constructs

  • Object Constraint Language specification documentdefinition of a (textual) language for expressing logical constraints

  • UML is ForFor ProblemsSpecifyingVisualizingPromoting UnderstandingDocumenting

    For SolutionsSpecifyingVisualizingEvaluatingConstructingDocumenting

  • For Problem SolvingCapturing AttemptsCommunicating AttemptsLeveraging Knowledge

  • Parts of UMLClass DiagramsmodelsObject Diagramsexample modelsUse Case Diagramsdocument who can do what in a systemSequence Diagramsshows interactions between objects used to implement a use caseCollaboration Diagramssame as above, different style

  • Parts of UML (Cont)Statechart Diagramspossible states and responses of a class and what transitions themActivity Diagramsdescribe the behaviour of a class in response to internal processingComponent DiagramsOrganization of and dependencies amongst software implementation componentsDeployment DiagramsDescribe the mapping of software implementation components onto processing nodes

  • The real world is impenetrably complexe.g., a complete model of you would include DNA, behaviour specifications, total history, parents history, influences, for a particular problem, abstracting you aslast namefirst namestudent numbercoursefinal grade

  • An object isA concept, abstraction, or thingwith crisp boundaries and meaning for the problem at handObjectspromote understanding of the real worldprovide a practical basis for computer implementation

  • Decomposition of a problem into objects depends onJudgmentThe nature of the problem being solvedNot only the domain: two analyses of the same domain will turn out differently depending upon the kind of programs we wish to produce.

  • ClassesA class describes a group of objects with similar properties.Class: InstructorObject: David PennyObject: Matthew Zaleski

  • Class: DepartmentObject: Department of Computer ScienceObject: Department of Electrical Engineering

  • AttributesData values held by the objects of a class

  • OperationsA function or a transformation that may be applied to or by objects in a class.Not often used (not often terribly useful) in an OOA

  • Links and AssociationsThe means for establishing relationships among objects and classes.link: a connection between two object instancesassociation: a collection of links with common structure and semantics.

  • Object DiagramsModels instances of things contained in class diagrams.Shows a set of objects and their links at a point in timeUseful preparatory to deciding on class structures.Useful in order to better explain more complex class diagrams by giving instance examples.

  • MultiplicityUsed to indicate the number of potential instances involved in the association when the other associated classes are fixed.InstructorDepartmentteaches for**

  • N-Ary AssociationsCourse*Try to avoid them!

  • Attributes on AssociationsInstructorDepartmentteaches for

  • Aggregation Indicators (Part-Of)DepartmentStudentImplied multiplicity of 1WindowFrameComposition(strong ownership, coincident lifetime) Aggregation(no associated semantics)

  • Generalization (a.k.a. Inheritance, is-a)Shape

  • Avoiding Morphing ClassesAnalysis shown below may not be a good choice, as objects of class 407 Instructor may teach other things and different things next term.Avoid situations where objects will need to morph classes

  • ExampleWe are asked to build a system for keeping track of the time our workers spend working on customer projects.We divide projects into activities, and the activities into tasks. A task is assigned to a worker, who could be a salaried worker or an hourly worker.Each task requires a certain skill, and resources have various skills at various level of expertise.

  • StepsAnalyze the written requirementsExtract nouns: make them classesExtract verbs: make them associationsDraw the OOA UML class diagramsDetermine attributesDraw object diagrams to clarify class diagrams

  • Steps (conti..)Determine the systems use casesIdentify ActorsIdentify use caseRelate use casesDraw sequence diagramsOne per use caseUse to assign responsibilities to classesAdd methods to OOA classes

  • ExampleWe are asked to build a system for keeping track of the time our workers spend working on customer projects.WorkerCustomerProjectTime

  • ExampleWe divide projects into activities, and the activities into tasks. A task is assigned to a worker, who could be a salaried worker or an hourly worker.ProjectWorker

  • ExampleEach task requires a certain skill, and workers have various skills at various level of expertise.WorkerSkillTask

  • StepsAnalyze the written requirementsExtract nouns: make them classesExtract verbs: make them associationsDraw the OOA UML class diagramsDetermine attributesDraw object diagrams to clarify class diagramsDetermine the systems use casesIdentify ActorsIdentify use caseRelate use cases

  • ExampleN.B. Project has no attribute in Customer association is enough no database id for Customer shown in an OOA, only include an id if visible to users may include such things during database design or OOD

  • ExampleCustomercontracts Task

  • ExampleActivitySkillWorkerrequiresassigned tohas

  • ExampleTaskassigned tohas

  • ExampleTaskWorkerassigned tospent on

  • StepsAnalyze the written requirementsExtract nouns: make them classesExtract verbs: make them associationsDraw the OOA UML class diagramsDetermine attributesDraw object diagrams to clarify class diagramsDetermine the systems use casesIdentify ActorsIdentify use caseRelate use casesDraw sequence diagramsOne per use caseUse to assign responsibilities to classesAdd methods to OOA classes

  • Object Diagrams

  • StepsAnalyze the written requirementsExtract nouns: make them classesExtract verbs: make them associationsDraw the OOA UML class diagramsDraw object diagrams to clarify class diagramsDetermine attributesDetermine the systems use casesIdentify ActorsIdentify use caseRelate use casesDraw sequence diagramsOne per use caseUse to assign responsibilities to classesAdd methods to OOA classes

  • Use CasesActors:Represent users of a systemhuman usersother systemsUse casesRepresent functionality or services provided by a system to its users

  • Use Case DiagramsTime & Resource Management System (TRMS) Backup SystemManage ResourcesLog TimeManage ProjectsAdminister System

  • Resource Manager Use CasesAdd SkillRemove SkillUpdate SkillFind Skill

  • More Resource Manager Use Cases

  • StepsAnalyze the written requirementsExtract nouns: make them classesExtract verbs: make them associationsDraw the OOA UML class diagramsDraw object diagrams to clarify class diagramsDetermine attributesDetermine the systems use casesIdentify ActorsIdentify use caseRelate use casesDraw sequence diagramsOne per use caseUse to assign responsibilities to classesAdd methods to OOA classes

  • Sequence Diagram Assign Skill to Worker Use CaseRes. Mgr. Win: UI:Worker:Skill:SkillLevel

  • StepsAnalyze the written requirementsExtract nouns: make them classesExtract verbs: make them associationsDraw the OOA UML class diagramsDraw object diagrams to clarify class diagramsDetermine attributesDetermine the systems use casesIdentify ActorsIdentify use caseRelate use casesDraw sequence diagramsOne per use caseUse to assign responsibilities to classesAdd methods to OOA classes

  • Add MethodsRead sequence diagrams to identify necessary methods

  • In DesignBring methods closer to implementation

  • In DesignBring methods closer to implementationWorkListInt getNumListElements();String getListElement(int n);ListModelint getNumListElements();String getListElement(int n);

  • In this paper, I take a look at the UML (Unified Modelling Language) notation for Object Oriented Analysis and Design - the emerging standard designed by Booch, Rumbaugh and Jacobson, each of whom previously had their own notations published independently.The starting point is Object Modelling, a technique that enables you to focus on class structure, inheritance, etc., whilst avoiding language specifics such as pointer dereferencing.

  • The best way to understand the notation is to look at an example. The following Object Model shows a simple Banking System, containing classes for Head-Office, Branch, Accounts held at that Branch, and the Customers who the Accounts belong to:

  • A Head-Office class (containing bankName and address fields, otherwise known as attributes) administers an (unspecified) number of Branch classes; whilst a Branch is administered-by exactly one Head-Office (the little black arrows indicates the direction in which the name given to a relationship should be read).

  • On the diagram this relationship is represented by the line from the Head-Office class to the Brach class which is labelled administers. The 1 at the Head-Office end of the line shows that exactly one Head-Office is associated with each Branch (as you would expect). The * at the Branch end of the line shows that a Head-Office administers many Branches - again as you would expect.

  • Similarly, a Branch class (which contains manager and address attributes) holds many Account classes; whilst each Account class is-held-by exactly one Branch. We can also see that we have determined that an Account class has a CalcCharges method Object Oriented Analysis And Design Using UML Page 4 of 17 W1 - Object Oriented Analysis And Design Using UML( Rev: 1) - 9/27/01 (also known as operations or member functions) defined. This method, when invoked, will look at the detail stored within the Account object, and apply the appropriate (undoubtedly extortionate) charges to the Account. The second method - PrintStatement - will take the details of the Account and print them out.

  • The inheritance triangle (labelled account-type) shows us that our system knows about three types of Account: the basic account (in this case a virtual class called Account), and two specialised accounts - the CurrentAccount and SavingsAccount - which are derived from Account. The fact that the CalcCharges is shown in both subclasses indicates that its implementation is re-defined for these classes (in C++ terms it is a virtual function). This is indicative of the fact that charges on a SavingsAccount are calculated in a completely different manner to charges on a CurrentAccount.

  • Each Account belongs-to exactly one owner - the Customer class on the diagram. Customers, on the other hand, may have many Accounts.Finally, you can see that there are two relationships shown between the Account and the Transaction classes. This is because, in our banking system, each individual transaction(credit, debit, etc.) must have two associated accounts - the Account the money is debit(ed)-from, and the Account the money is credit(ed)-to. This enables the bank to record exactly where each transaction has come from, and gone to, so to speak.

  • This can be shown more clearly by the following instance diagram (instance diagrams are used to assist in understanding and clarifying Object Models - they also give quite a hint as to how relationships can be implemented in C++!):