Object Oriented Analysis and Design Using the UML · PDF filereplaceable part of a system that fulfills a clear ... in the Java API, ... Object Oriented Analysis and Design Using the

  • Upload
    lephuc

  • View
    221

  • Download
    1

Embed Size (px)

Citation preview

  • Object Oriented Analysis and Design Object Oriented Analysis and Design

    Using the UMLUsing the UML

    Introduction to Object Orientation

    (abbreviated!)

  • Objectives: Introduction to Object Objectives: Introduction to Object

    OrientationOrientation Understand the basic principles of object

    orientation

    Understand the basic concepts and terms

    of object orientation and the associated

    UML notation

    Appreciate the strengths of object

    orientation

    Understand some basic UML modeling

    mechanisms

  • Object Orientation

    En

    cap

    sula

    tio

    n

    Ab

    stra

    ctio

    n

    Hie

    rarc

    hy

    Mo

    du

    lari

    ty

    1. Basic Principles of Object 1. Basic Principles of Object

    OrientationOrientation

    Know This.

  • Salesperson

    Not saying

    which

    salesperson

    just a

    salesperson in

    general!!!

    Customer Product

    Manages Complexity

    What is Abstraction?What is Abstraction?

  • Improves Resiliency

    What is Encapsulation?What is Encapsulation? Hide implementation from clients

    Clients 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

    System

    Billing

    Order

    Entry

    Order

    Fulfillment

    Manages Complexity

    What is Modularity?What is Modularity?

    The breaking up of something complex

    into manageable pieces

  • Decreasing

    abstraction

    Increasing

    abstraction

    Asset

    RealEstate

    Savings

    BankAccount

    Checking Stock

    Security

    Bond

    Elements at the same level of the hierarchy should be at the same level of abstraction

    What is Hierarchy? What is Hierarchy?

    Levels of abstraction

  • 2. Basic Concepts of Object 2. Basic Concepts of Object

    OrientationOrientation Object

    Class

    Attribute

    Operation

    Interface (Polymorphism)

    Component

    Package

    Subsystem

    Relationships

  • A More Formal Definition A 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:

    State

    Behavior

    Identity

    Know This.

  • : Professor

    Professor Clark

    a + b = 10

    ProfessorClark :

    Professor

    ProfessorClark

    Class Name Only

    Object Name Only

    Class and Object Name (stay tuned for classes)

    Representing Objects Representing Objects the the

    beginningsbeginnings An object is represented as a rectangle with

    underlined name (no class name shown

    here) (unnamed object)

  • OO Principle: Abstraction

    What is a Class?What 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 class

  • Professor

    Professor Clark

    a + b = 10

    Representing ClassesRepresenting Classes

    A class is represented using a

    compartmented rectangle

    (note: no underlining)

  • Professor name empID

    create( ) save( ) delete( ) change( )

    Class Name

    Attributes

    Operations

    Class Compartments Class Compartments a bit a bit

    more developmentmore development A class is comprised of three

    sections

    The first section contains the class name

    The second section shows the structure (attributes)

    The third section shows the behavior (operations)

  • Objects Class

    Professor Smith

    Professor Jones

    Professor Mellon

    Professor

    The Relationship Between The Relationship Between

    Classes and ObjectsClasses and Objects A class is an abstract definition of an object

    It defines the structure and behavior of each object in the class

    It serves as a template for creating objects

  • :CourseOffering

    number = 101

    startTime = 900

    endTime = 1100

    :CourseOffering

    number = 104

    startTime = 1300

    endTime = 1500

    CourseOffering

    number

    startTime

    endTime

    Class

    Attribute

    Object

    Specific

    attribute values

    for different

    objects

    What is an Attribute?What is an Attribute?

  • CourseOffering

    addStudent

    deleteStudent

    getStartTime

    getEndTime

    Class

    Operation

    What is an Operation? (very What is an Operation? (very

    general form here)general form here)

    Really need to show more, but here, this is sufficient.

  • Source File

    Name

    Executable

    Name

    OO Principle:

    Encapsulation

    What is a Component?What is a Component? A non-trivial, 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 component

    A run time component or

    An executable component

    Component

    Name Component

    Interface

  • Package Name OO Principle:

    Modularity

    What is a Package?What is a Package? A package is a general purpose mechanism for organizing like

    elements into groups A model element which can contain other model elements Think: in the Java API, similar classes are found in packages that

    we may import, etc.

    Uses Organize the model under development

    A unit of configuration management

    Think: Math class. (contains math classes such as cos() )

    Know This

  • Example for Data Structures Class:Example for Data Structures Class:

    Think IO package you imported. Inside this package are many (often) unrelated

    classes. FileReader BufferedReader FileWriter PrinterWriter, etc.

    To USE any of these classes, we merely create an object of them and proceed independently of any other classes.

    To USE any of these classes in the package, we go directly to the class, instantiate the class, and use the methods in the objects.

  • OO Principles: Encapsulation and Modularity

    Subsystem Name

    Interface Interface

    Realization Subsystem

    (stay tuned for realization relationship)

    What is a Subsystem?What is a Subsystem? A combination of a package (contains other model

    elements) and a class (has behaviors)

    A subsystem: realizes one or more interfaces which

    define its behavior

    Interface is an abstract class. Subsystems implement (realize) the interface(s)

    Know This.

  • Example of SubsystemsExample of Subsystems

    Subsystem Name

    Interface Interface

    Realization Subsystem

    Subsystem might be AccountsReceivable, AccountsPayable, Billing,

    That is, a major hunk of functionality.

    BUT, a client of the subsystem does NOT have access to the individual

    Classes like in a Package. Rather, a client must go through the

    public Interface to the subsystem, which contains the signatures of the

    services provided within the subsystem.

    The contents of the subsystem are NOT directly accesses;

    They are protected;

    Only the services shown in the interface are made available to clients.

  • RelationshipsRelationships

    Association

    Aggregation

    Composition

    Dependency

    Generalization

    Realization

  • Professor University Works for

    Class

    Association

    Association Name

    Professor University

    Employer Employee

    Role Names

    Relationships: Relationships:

    AssociationAssociation Models a semantic connection among classes

  • Student Schedule

    Whole

    Aggregation sometimes called

    simple aggregation.

    This is sometimes called a

    has_a relationship

    Part

    Relationships: Relationships: Aggregation Aggregation

    (simple aggregate)(simple aggregate) A special form of association that models a

    whole-part relationship between an aggregate

    (the whole) and its parts

    Know This

  • Student Schedule

    Whole

    Aggregation

    This one is called

    composition.

    Part

    Relationships: Relationships: CompositionComposition

    A form of aggregation with strong

    ownership and coincident lifetimes

    The parts cannot survive the whole/aggregate

    Know This

  • Association: Multiplicity and Association: Multiplicity and

    NavigationNavigation Multiplicity defines how many objects participate

    in a relationship Multiplicity is a Structural Relationship! The number of instances (that is, objects) of one

    class related to ONE instance of another class (examples ahead)

    Specified for each end of the association

    Associations and aggregations are bi-directional by default, but it is often desirable to restrict navigation to one direction If navigation is restricted, an arrowhead is

    added to indicate the direction of the navigation

  • Association: MultiplicityA