Chapter2 New

Embed Size (px)

Citation preview

  • 7/29/2019 Chapter2 New

    1/40

  • 7/29/2019 Chapter2 New

    2/40

    Objects Object means a combination of data and logic that

    represent some real world entity

    Eg. Saab Automobile can be represented in a computerprogram as an object.

    The data part of this object would be the cars name,colour, number, price

    The logic part could be a collection of program Show mileage, change mileage, stop, go

    2

  • 7/29/2019 Chapter2 New

    3/40

    Objects

    3

    Object Attribute/data Behaviors/logic

    Book with title

    Object OrientedAnalysis Design

    Rent,

    available,

    reserved

    Add(),

    Update(),

  • 7/29/2019 Chapter2 New

    4/40

    Class Classes are used to distinguish one type of object from

    another.

    A class is a set of object that share a common structure

    and common behaviour.

    A single object is simply an instance of a class.

    The chief role of a class is to define the properties andprocedure and applicability of an instances

    4

  • 7/29/2019 Chapter2 New

    5/40

    Object Behaviour and methods

    5

    Employee16

    name: John

    address: M Street No.23

    dateOfBirth: 02/10/65

    employeeNo: 324

    socialecurityNo:E342545

    department: Sale

    Eployee16.join(02/05/1997)Eployee16.retire(03/08/2005)

    Eployee16.changeDetail(X

    Street No. 12)

    Object State and properties

    Employee

    name: String

    address: String

    dateOfBirth: Date

    employeeNo: int

    socialecurityNo:String

    department: String

    Join();

    Retire();

    changeDetail();

  • 7/29/2019 Chapter2 New

    6/40

    Object Respond to Messages Objects capabilities are determined by the methods

    define for it.

    Methods conceptually are equivalent to the functiondefinitions used in procedural languages.

    To do an operation ,a message is sent to an object

    Eg: car object knows how to respond to the stop

    message,

    6

  • 7/29/2019 Chapter2 New

    7/40

    What is Abstraction?

    7

    Salesperson

    Not saying

    Which

    salesperson

    just asalesperson

    in general!!!

    CustomerProduct

  • 7/29/2019 Chapter2 New

    8/40

    What is Encapsulation? Hide implementation from clients Clients depend on interface

    8

    Improves Resiliency

    How does an object encapsulate?What does it encapsulate?

  • 7/29/2019 Chapter2 New

    9/40

    Inheritance Object classes may inherit attributes and services from

    other object classes.

    Inheritance represents the generalization of a class.

    9

  • 7/29/2019 Chapter2 New

    10/40

    Inheritance Object classes may inherit attributes and services from

    other object classes.

    Inheritance represents the generalization of a class.

    10

  • 7/29/2019 Chapter2 New

    11/40

    A generalisation hierarchy

    11

    Employee

    Programmer

    projectprogLanguage

    Manager

    ProjectManager

    budgetsControlled

    dateAppointed

    projects

    Dept.Manager

    StrategicManager

    dept responsibilities

  • 7/29/2019 Chapter2 New

    12/40

    Multiple inheritance Rather than inheriting the attributes and services

    from a single parent class, a system which supports

    multiple inheritance allows object classes toinherit from several super-classes

    Can lead to semantic conflicts whereattributes/services with the same name in different

    super-classes have different semantics Makes class hierarchy reorganisation more

    complex

    12

  • 7/29/2019 Chapter2 New

    13/40

    Multiple inheritance

    13

    # Tapes

    Talking book

    AuthorEdition

    Publication date

    ISBN

    Book

    SpeakerDurationRecording date

    Voice recording

  • 7/29/2019 Chapter2 New

    14/40

    Advantages of inheritance

    It is an abstraction mechanism which may be used toclassify entities

    It is a reuse mechanism at both the design and theprogramming level

    The inheritance graph is a source of organisationalknowledge about domains and systems

    14

  • 7/29/2019 Chapter2 New

    15/40

    Polymorphism

    the ability of different objects to perform theappropriate method in response to the samemessage is known as polymorphism.

    the selection of the appropriate method depends

    on the class used to create the object

    15

    Shape

    SquareCircle

    name

    getName( )

    calculateArea( )

    side

    calculateArea( )

    radius

    calculateArea( )

  • 7/29/2019 Chapter2 New

    16/40

    Object Relationships and Association

    16

    pilot Planes

    Association represent the relationship betweenobjects and classes

    Association are bidirectional that they means they

    can be traversed in both directions.An important issue is cardinalitywhich specifies how

    many instances of one class may relate to a singleinstance of an associated class

    Can Fly flown by

  • 7/29/2019 Chapter2 New

    17/40

    What is OOAD?

    Object-oriented analysis and design (OOAD) is asoftware engineering approach that models a system as agroup of interacting objects .

    Analysisunderstanding, finding and describingconcepts in the problem domain.

    Designunderstanding and defining softwaresolution/objects that representthe analysis concepts andwill eventually be implemented in code.

    OOADAnalysis is object-oriented and design isobject-oriented. A software development approach thatemphasizes a logical solution based on objects.

    17

  • 7/29/2019 Chapter2 New

    18/40

    Definitions of OOA and OODWhat is Object Oriented Analysis? Object-oriented analysis (OOA) applies object-modeling

    techniques to analyze the functional requirements for a

    system.

    What is Object Oriented Design?

    Object-oriented design (OOD) elaborates the analysis

    models to produce implementation specifications.

    OOA focuses on what the system does, OOD on how thesystem does it.

    18

  • 7/29/2019 Chapter2 New

    19/40

    Object Oriented Design OOD transforms the analysis model created using OOA

    into a design model that serves as a blueprint for softwareconstruction.

    OOD results in a design that achieves a number of differentlevels of modularity.

    Subsystems: Major system components. Objects: Data and the operations. Four important software design concepts:

    Abstraction Information Hiding Functional Independence Modularity

    19

    C i

  • 7/29/2019 Chapter2 New

    20/40

    Comparison

    20

    OO:

    Systems decomposed intocollections of data objects;

    function + data in one place =>

    System components more

    independent => more resilient

    to requirements and

    maintenance changes.

    Inheritance and polymorphism

    are possible => reuse,

    extension, and tailoring of

    software/designs is possible.

    Closely mirrors how humans

    decompose and solve

    complex.

    Structured:

    Systems decomposed into functions;functions and data modelled separately

    =>

    System components are more

    dependent on each other =>

    requirements and

    maintenance changes more

    difficult

    Inheritance and polymorphism

    not possible => limited reuse

    possible.

    System components do not

    map closely to real-world

    entities => difficult to manage

    complexity.

  • 7/29/2019 Chapter2 New

    21/40

    Comparison

    21

    OO:

    Process allows foriterative andincremental development =>

    Integration of programs is

    series of incremental

    prototypes. Users and developers get

    important feedback

    throughout development.

    Testing resources distributed

    more evenly.

    If time is short, coding and

    testing can begin before the

    design is finished.

    Structured:

    Process less flexible and largely linear=>

    Integration of programs is big

    bang effect.

    Users or developers providedwith little or no feedback; see

    system only when it has been

    completed.

    Testing resources are

    concentrated in the

    implementation stage only.

    Coding and testing cannot

    begin until all previous stages

  • 7/29/2019 Chapter2 New

    22/40

    OOD

    The subsystem layer:Representation of each of thesubsystems that enable thesoftware to achieve its customerdefined requirements.

    The class and object layer: Theclass hierarchies, (generalization)

    and representation of objects. The message layer: The design

    details of communication of eachobject with its collaborators.(external and internal interfaces)

    The responsibilities layer: DataStructure and algorithmic designfor all attributes and operations.

    22

  • 7/29/2019 Chapter2 New

    23/40

    OOA to OOD

    23

  • 7/29/2019 Chapter2 New

    24/40

    OOA to OOD

    24

  • 7/29/2019 Chapter2 New

    25/40

    Design Issues decomposabilitythe facility with which a design methodhelps the designer to decompose a large problem intosubproblems that are easier to solve;

    composabilitythe degree to which a design method

    ensures that program components (modules), oncedesigned and built, can be reused to create other systems; understandabilitythe ease with which a program

    component can be understood without reference to otherinformation or other modules;

    continuitythe ability to make small changes in a program

    and have these changes manifest themselves withcorresponding changes in just one or a very few modules; protectiona architectural characteristic that will reduce

    the propagation of side affects if an error does occur in agiven module.

    25

  • 7/29/2019 Chapter2 New

    26/40

    www.intelligroup.com | Copyright 2009 Intelligroup, Inc. | | PRIVATE AND CONFIDENTIAL | INTELLIGROUP proprietary.

    Process Flow for OOD

    26

    http://www.intelligroup.com/http://www.intelligroup.com/
  • 7/29/2019 Chapter2 New

    27/40

    Unified Modeling Language

    27

    UML Di

  • 7/29/2019 Chapter2 New

    28/40

    UML DiagramWhat is UML?The Unified Modeling Language (UML) is a standard language for

    28

    Specifying Visualizing Constructing Documenting

    Business Modeling Communications

  • 7/29/2019 Chapter2 New

    29/40

    Different Views

    29

    Users Designers Analyzers

  • 7/29/2019 Chapter2 New

    30/40

    UML- Eight Diagrams and One

    Language Use Case Diagram

    Class Diagram/Object Diagram

    State Diagram

    Sequence Diagram

    Collaboration Diagram

    Activity Diagram

    Component Diagram

    Deployment Diagram

    30

  • 7/29/2019 Chapter2 New

    31/40

    Use case diagram

    31

    Online C2C shopping

    overview the usage requirements

    presentations project stakeholders

    "the meat" of the actual requirements

    Actor

    Actor:

    An actor is a person, organization, or

    external system that plays a role inone or more interactions with your

    system

    Use case

    Use case:

    A use case describes a sequence of

    actions that provide something ofmeasurable value to an actor and is

    drawn as a horizontal ellipse

    Systemboundary

    System boundary:

    indicates the scope of your

    system. Anything within the boxrepresents functionality that is in

    scope and anything outside the box

    is not

  • 7/29/2019 Chapter2 New

    32/40

    Class Diagram

    32

    Class diagrams show the classes of the

    system, their interrelationships (including

    inheritance, aggregation, and

    association), and the operations andattributes of the classes.

    Name

    Attributes

    Operations

    Relations

    Associations

    Aggregation

    Generalization

  • 7/29/2019 Chapter2 New

    33/40

    Relationships between Class Diagrams

    Association -- a relationship between instances of the two classes. Thereis an association between two classes if an instance of one class mustknow about the other in order to perform its work. In a diagram, an

    association is a link connecting two classes.

    Aggregation -- an association in which one class belongs to a collection.An aggregation has a diamond end pointing to the part containing thewhole.

    Generalization -- an inheritance link indicating one class is a superclassof the other. A generalization has a triangle pointing to the superclass.

    33

  • 7/29/2019 Chapter2 New

    34/40

    Activity Diagram

    34

    Activity diagrams describe the

    workflow behaviour of a system

    Start

    Fork

    Branch

    MergeJoint

    End

  • 7/29/2019 Chapter2 New

    35/40

    State Machine DiagramAState Machine diagram

    shows the possible states of

    the object and the transitions

    that cause a change in state.

    35

    ?What is different

    between activities

    and Statemachinediagram

  • 7/29/2019 Chapter2 New

    36/40

    Sequence DiagramA Sequence diagram depicts the sequence of actions

    that occur in a system. The invocation of methods ineach object, and the order in which the invocation

    occurs is captured in a Sequence diagram.

    36

  • 7/29/2019 Chapter2 New

    37/40

    Collaboration Diagram The collaboration diagram illustrates messages being

    sent between classes and objects (instances).

    37

  • 7/29/2019 Chapter2 New

    38/40

    Component DiagramAcomponent diagram in the Unified Modeling

    Language, depicts how components are wired togetherto form larger components and or software systems.

    38

  • 7/29/2019 Chapter2 New

    39/40

    Deployment Diagram deployment diagram specifies a set of constructs that

    can be used to define the execution architecture ofsystems that represent the assignment of software

    artifacts to nodes.

    39

  • 7/29/2019 Chapter2 New

    40/40

    QUESTIONS