Object Oriented Analysis & Design - Warwick

2y ago
9 Views
2 Downloads
573.04 KB
43 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Matteo Vollmer
Transcription

Object Oriented Analysis & DesignLecture # 3Department of Computer Science and TechnologyUniversity of BedfordshireWritten by David Goodwin,based on the book Applying UML and Patterns (3rd ed.)by C. Larman (2005).Modelling and Simulation, 2012

OutlineIntroduction to Object eObjectOrientedAnalysis &DesignIntroduction cePackage

ObjectOrientedAnalysis &DesignIntroduction toObjectOrientationIntroduction toObject e

Object OrientationObjectOrientedAnalysis &DesignIntroduction toObjectOrientationIIKnowing and object-oriented language (such as Java) isa necessary but insufficient step to create objectsystems.UML is just a diagramming tool; it’s full use isn’trealised without object oriented licityPolymorphismEncapsulationInterfacePackage

ObjectOrientedAnalysis &DesignOOA/DIObject-oriented analysis (OOA):IIIprocess of analysing a task (also known as a problemdomain)finding and describing objectstypical:IIIIset of use casesone or more class diagramsa number of interaction diagramsObject-oriented design (OOD):IIIdefining software objects and how they collaborate tofulfill the requirements.constraints to conceptual model produced inobject-oriented analysisConcepts in the analysis model are mapped ontoimplementation classes and interfaces resulting in amodel of the solution domain.Introduction cePackage

ObjectOrientedAnalysis &DesignIntroduction InterfacePackage

Definition of an objectIObject:IIObjects directly relate to real-world ‘entities’.An object has identity, state & behaviour.IIIIIIdentity: the property of an object that distinguishes itfrom other objectsState: describes the data stored in the objectBehaviour: describes the methods in the object’sinterface by which the object can be usedThe state of an object is one of the possible conditionsin which an object may exist.The state of an object is represented by the values of itsproperties (attributes).ObjectOrientedAnalysis &DesignIntroduction cePackage

Definition of an objectIReal-world objects share three gs have state (name, color, breed, hungry)Bicycles also have state (current gear, current pedalcadence, current speed)Behaviour:IIDogs have behaviour (barking, fetching, wagging tail)Bicycles also have behaviour (changing gear, changingpedal cadence, applying brakes)ObjectOrientedAnalysis &DesignIntroduction cePackage

Identifying & using objects’ statesObjectOrientedAnalysis &DesignI“What possible states can this object be in?”I“What possible behaviour can this object perform?”Introduction toObjectOrientationISome objects will contain other objects.By attributing state (current speed, current pedalcadence, and current gear) and providing methods forchanging that state, the object remains in control ofhow the outside world is allowed to use it.ObjectsIIif the bicycle only has 6 gears, a method to changegears could reject any value that is less than 1 orgreater than rphismEncapsulationInterfacePackage

Advantages of using objectsIObjectOrientedAnalysis &DesignBundling code into individual software objects providesa number of benefits, including:IModularity:IIInformation-hiding:IIBy interacting only with an object’s methods, thedetails of its internal implementation remain hiddenfrom the outside world.Code re-use:IIThe source code for an object can be written andmaintained independently of the source code for otherobjects.If an object already exists, you can use that object inyour program.Pluggability and debugging ease:IIf a particular object turns out to be problematic, youcan simply remove it from your application and plug ina different object as its replacement.Introduction cePackage

ObjectOrientedAnalysis &DesignIntroduction terfacePackage

What is a Class?IMany individual objects can be of the same kind:IIIIThere may be thousands of other bicycles in existence,all of the same make and model.Each bicycle was built from the same set of blueprintsand therefore contains the same components.In object-oriented terms, we say that your bicycle is aninstance of the class of objects known as bicycles.A class is the blueprint from which individual objectsare created.ObjectOrientedAnalysis &DesignIntroduction cePackage

Class example in JavaObjectOrientedAnalysis &DesignIntroduction toObjectOrientationObjectsI The fields cadence, speed,and gear represent theobject’s state, and themethods (changeCadence,changeGear, speedUp etc.)define its cityPolymorphismEncapsulationInterfacePackage

Class example in JavaI Not a completeapplication; it’s justthe blueprint forbicycles that might beused in an application.The responsibility ofcreating and using newBicycle objects belongsto some other class inyour application.ObjectOrientedAnalysis &DesignIntroduction cePackage

Class notationObjectOrientedAnalysis &DesignIntroduction toObjectOrientationName appears in the topdivision of the class boxObjectsClassAttributesAttribute appears in the middledivision of the class boxOperation appears in the bottomdivision of the class ationInterfacePackage

What is an attribute?IAn element of data that helps to describe an object.IAttribute types may be restricted by a programminglanguage.IA class that includes many attributes may bedecomposed into other classes.ObjectOrientedAnalysis &DesignIntroduction sAssociationsAggregationCompositionIComplex attribute lists in a class may be PolymorphismEncapsulationInterfacePackage

What is an operation?IIt helps to specify the behaviour of a class (object).ICan use the syntax of a programming language.Specify the visibility of each operation:IIIIIpublic ( );private (-);protected (#).Consider the responsibilities of each class:IIResponsibilities often imply more than one operation.A method is the implementation of an operation.ObjectOrientedAnalysis &DesignIntroduction cePackage

Class AssociationsObjectOrientedAnalysis &DesignIntroduction toObjectOrientationIClasses (objects) must interact with each other so thata piece of software can do something.ObjectsClassAttributesIHow do classes/objects therefore interact?OperationsIHow are associations nInterfacePackage

Class AssociationsIAn association represents a family of links.IBinary associations (with two ends) are normallyrepresented as a line.IIAn association can be named, and the ends of anassociation can be adorned with role names, ownershipindicators, multiplicity, visibility, and other properties.There are four different types of association:IIbi-directional, uni-directional, Aggregation (includesComposition aggregation) and Reflexive.Bi-directional and uni-directional associations are themost common ones.IFor instance, a flight class is associated with a planeclass bi-directionally. Association represents the staticrelationship shared among the objects of two classes.Example: “department offers courses”, is an associationrelationObjectOrientedAnalysis &DesignIntroduction cePackage

AggregationIWhole/Part relationship.I‘Smaller’ classes are parts of ‘larger’ classes.IObjects belonging to an aggregate can belong to morethan one class.ObjectOrientedAnalysis &DesignIntroduction sAssociationsAggregationIEach class that makes up an aggregation relationship isa class in its own PolymorphismEncapsulationInterfacePackage

AggregationIIAggregation is a variant of the “has a” or associationrelationship; aggregation is more specific thanassociation.It is an association that represents a part-whole orpart-of relationship.ObjectOrientedAnalysis &DesignIntroduction toObjectOrientationObjectsClassIIIIAs a type of association, an aggregation can be namedand have the same adornments that an association can.However, an aggregation may not involve more thantwo classes.Aggregation can occur when a class is a collection orcontainer of other classes, but where the containedclasses do not have a strong life cycle dependency onthe container-essentially,if the container is destroyed, its contents are ismEncapsulationInterfacePackage

Aggregation NotationObjectOrientedAnalysis &DesignIntroduction cePackage

CompositionObjectOrientedAnalysis &DesignIntroduction toObjectOrientationIA stronger form of aggregation.IObjects may only be part of one composite at a time.IThe composite object has sole responsibility for thecreation and destruction of all of its icityPolymorphismEncapsulationInterfacePackage

CompositionIIComposition is a stronger variant of the “owns a” orassociation relationship; composition is more specificthan aggregation.Composition usually has a strong life cycle dependencybetween instances of the container class and instancesof the contained class(es):IIf the container is destroyed, normally every instancethat it contains is destroyed as well.ObjectOrientedAnalysis &DesignIntroduction cePackage

Composition NotationObjectOrientedAnalysis &DesignIntroduction cePackage

Aggregation vs. CompositionIWhen attempting to represent real-world whole-partrelationships,IIe.g., an engine is a part of a car, the compositionrelationship is most appropriate.However, when representing a software or databaserelationship,IIObjectOrientedAnalysis &Designe.g., car model engine ENG01 is part of a car modelCM01, an aggregation relationship is best, as theengine, ENG01 may be also part of a different carmodel.The whole of a composition must have a multiplicity of0.1 or 1, indicating that a part must belong to only onewhole; the part may have any multiplicity.IFor example, consider University and Departmentclasses. A department belongs to only one university, soUniversity has multiplicity 1 in the relationship. Auniversity can (and will likely) have multipledepartments, so Department has multiplicity 1.*.Introduction cePackage

ObjectOrientedAnalysis &DesignIntroduction tionInterfacePackage

Inheritance (Generalisation)IIIInheritance is a code reuse mechanism to build newobjects out of old ones.Inheritance defines a relationship among classes whereone or more classes share the behaviour and/orattributes of another class.For example, a class called ink-jet printer inherits all thebehaviour and attributes of the class computer printer.ObjectOrientedAnalysis &DesignIntroduction sAssociationsAggregationCompositionIInheritance also enables ‘polymorphism’.InheritanceIThe relationship superclass and subclass is used.DependencyIEach subclass is a specialised version of its superclass.MultiplicityIWithin UML, generalisation is the preferred term.PolymorphismEncapsulationInterfacePackage

Inheritance (Generalisation)IDifferent kinds of objects often have a certain amountin common with each other.IIIMountain bikes, road bikes, and tandem bikes, forexample, all share the characteristics of bicycles (currentspeed, current pedal cadence, current gear).Additional features that make them different: tandembicycles have two seats and two sets of handlebars; roadbikes have drop handlebars; some mountain bikes havean additional chain ring, giving them a lower gear ratio.Object-oriented programming allows classes to inheritcommonly used state and behavior from other classes.IIn this example, Bicycle now becomes the superclass ofMountainBike, RoadBike, and TandemBike.ObjectOrientedAnalysis &DesignIntroduction cePackage

Generalisation NotationObjectOrientedAnalysis &DesignIntroduction cePackage

ObjectOrientedAnalysis &DesignIntroduction ionInterfacePackage

DependencyIIIWeaker form of relationship which indicates that oneclass depends on another.One class depends on another if the latter is aparameter variable or local variable of a method of theformer.This is different from an association, where an attributeof the former is an instance of the latter.ObjectOrientedAnalysis &DesignIntroduction cePackage

ObjectOrientedAnalysis &DesignIntroduction ationInterfacePackage

MultiplicityIIThe association relationship indicates that (at least) oneof the two related classes makes reference to the other.The UML representation of an association is a line withan optional arrowhead indicating the role of theobject(s) in the relationship, and an optional notationat each end indicating the multiplicity of instances ofthat entity (the number of objects that participate inthe association).IIII0.1 No instances, or one instance (optional)1 Exactly one instance0.* or * Zero or more instances1.* One or more instances (at least one)ObjectOrientedAnalysis &DesignIntroduction cePackage

ObjectOrientedAnalysis &DesignIntroduction ationInterfacePackage

PolymorphismIPolymorphism means having many forms.IInvokes many different kinds of behaviour.IIt requires an inheritance hierarchy to be present.IEach class in an inheritance hierarchy is dependentupon other classes, and are therefore not classes in theirown right.ObjectOrientedAnalysis &DesignIntroduction sAssociationsAggregationIIobjects of various types define a common interface ofoperations for usersthe “ ” operator which allows similar or polymorphictreatment of numbers (addition), strings(concatenation), and lists plicityPolymorphismEncapsulationInterfacePackage

ObjectOrientedAnalysis &DesignIntroduction lationInterfacePackage

EncapsulationIEncapsulation is the process of hiding theimplementation details of an object.IThe only access to manipulate the object data isthrough its interface.IIt protects an object’s internal state from beingcorrupted by other objects.IIIAlso, other objects are protected from changes in theobject implementation.Encapsulation allows objects to be viewed as ‘blackboxes’.Communication is achieved through an ‘interface’.ObjectOrientedAnalysis &DesignIntroduction cePackage

ObjectOrientedAnalysis &DesignIntroduction onInterfacePackage

InterfaceIObject’s interface with the outside world;IIIIthe buttons on the front of your television set, forexample, are the interface between you and the electricalwiring on the other side of its plastic casing. You pressthe “power” button to turn the television on and off.In its most common form, an interface is a group ofrelated methods with empty bodies.Implementing an interface allows a class to becomemore formal about the behaviour.Interfaces form a contract between the class and theoutside world.ObjectOrientedAnalysis &DesignIntroduction cePackage

ObjectOrientedAnalysis &DesignIntroduction InterfacePackage

PackageIA package is a namespace that organises a set ofrelated classes and interfaces.IIIConceptually you can think of packages as being similarto different folders on your computer.You might keep HTML pages in one folder, images inanother, and scripts or applications in yet another.Because software can be composed of hundreds orthousands of individual classes, it makes sense to keepthings organised by placing related classes andinterfaces into packages.ObjectOrientedAnalysis &DesignIntroduction cePackage

Packages in JavaIThe Java platform provides an enormous class library (aset of packages) suitable for use in your ownapplications. This library is known as the “ApplicationProgramming Interface”, or “API”.IIIIa String object contains state and behavior for characterstrings;a File object allows a programmer to easily create,delete, inspect, compare, or modify a file on thefilesystem;a Socket object allows for the creation and use ofnetwork sockets;various GUI objects control buttons and checkboxes andanything else related to graphical user interfaces.ObjectOrientedAnalysis &DesignIntroduction ndencyMultiplicityIThere are literally thousands of classes to choose from.This allows you, the programmer, to focus on thedesign of your particular application, rather than theinfrastructure required to make it work.PolymorphismEncapsulationInterfacePackage

Object Oriented Analysis & Design Introduction to Object Orientation Objects Class Attributes Operations Associations Aggregation Composition Inheritance Dependency Multiplicity Polymorphism Encapsulation Interface Package Object Orientation I Knowing and object-oriented language (such as Java) is a necessary but insu cient step to create .

Related Documents:

method dispatch in different object-oriented programming languages. We also include an appendix on object-oriented programming languages, in which we consider the distinction between object-based and object-oriented programming languages and the evolution and notation and process of object-oriented analysis and design, start with Chapters 5 and 6;

Object Class: Independent Protection Layer Object: Safety Instrumented Function SIF-101 Compressor S/D Object: SIF-129 Tower feed S/D Event Data Diagnostics Bypasses Failures Incidences Activations Object Oriented - Functional Safety Object: PSV-134 Tower Object: LT-101 Object Class: Device Object: XS-145 Object: XV-137 Object: PSV-134 Object .

as object–oriented design. Object–oriented development approaches are best suited to projects that will imply systems using emerging object technologies to construct, manage, and assemble those objects into useful computer applications. Object oriented design is the continuation of object-oriented analysis,

University of Warwick c.cuevas-lopez@warwick.ac.uk Dan Bernhardt Department of Economics University of Warwick University of Illinois danber@illinois.edu Mario Sanclemente Department of Economics University of Warwick Mario.Sanclemente-Villegas@warwick.ac.uk April 18, 2018 Clickherefor the latest version Abstract

Object oriented design methods emerged in the 1980s, and object oriented analysis methods emerged during the 1990s. In the early stage, object orientation was largely . and extensible system. Whole object oriented modeling is covered by using three kinds of models for a system description. These models are: object model,

Reusability, CK Metric, Object - Oriented. 1. INTRODUCTION Object oriented systems continue to share a major portion of software development and customer base for these systems is on the rise. This is because there are many advantages in taking the object oriented concept. The weakness though is that most object oriented systems tend to be .

An Object-Oriented Analysis and Design course provides practical guidance on the construction of object-oriented systems. Specifically, you will gain a solid footing in the Software Development Life Cycle (SDLC), and a mastery of object-oriented analysis and design. We will also cover the Unified Modeling

According to ASTM E562-08 [8] a manual point-count on 30 evenly distributed fields with a 100-point-layer each on a Olympus BX60M with a JVC TK-C181 Color-video-camera, using the Piscara 9.4-software was conducted, from which the porosity could be calculated. adhesion (glue and braze testing) According to ASTM C633 [9] a tensile-strength-test on glued and brazed coatings with a surface .