Lecture 1 for Chapter 8, Object Design: Reusing Pattern Solutions - PowerPoint PPT Presentation


PPT – Lecture 1 for Chapter 8, Object Design: Reusing Pattern Solutions PowerPoint presentation | free to view - id: 19d0ae-ZDc1Z


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation

Lecture 1 for Chapter 8, Object Design: Reusing Pattern Solutions


Object design is the process of adding details to the requirements analysis and ... Wale. Bernd Bruegge & Allen Dutoit OOSE: ch08lect1r1.ppt 19 ... – PowerPoint PPT presentation

Number of Views:87
Avg rating:5.0/5.0
Slides: 50
Provided by: bernd181


Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: Lecture 1 for Chapter 8, Object Design: Reusing Pattern Solutions

Chapter 8, Object Design Reuse and Patterns I
Object Design
  • Object design is the process of adding details to
    the requirements analysis and making
    implementation decisions
  • The object designer must choose among different
    ways to implement the analysis model with the
    goal to minimize execution time, memory and other
    measures of cost.
  • Requirements Analysis Use cases, functional and
    dynamic model deliver operations for object model
  • Object Design Iterates on the models, in
    particular the object model and refine the models
  • Object Design serves as the basis of

Object Design Closing the Gap
Examples of Object Design Activities
  • Identification of existing components
  • Full definition of associations
  • Full definition of classes (System Design gt
    Service, Object Design gt API)
  • Specifying the contract for each component
  • Choosing algorithms and data structures
  • Identifying possibilities of reuse
  • Detection of solution-domain classes
  • Optimization
  • Increase of inheritance
  • Decision on control
  • Packaging

A More Detailed View of Object Design Activities
Detailed View of Object Design Activities (ctd)
A Little Bit of Terminology Activities
  • Object-Oriented methodologies use these terms
  • System Design Activity
  • Decomposition into subsystems
  • Object Design Activity
  • Implementation language chosen
  • Data structures and algorithms chosen
  • Structured analysis/structured design uses these
  • Preliminary Design Activity
  • Decomposition into subsystems
  • Data structures are chosen
  • Detailed Design Activity
  • Algorithms are chosen
  • Data structures are refined
  • Implementation language is chosen
  • Typically in parallel with preliminary design,
    not a separate activity

Plan for the next Lectures
Today we Start here
  • 1. Reuse Identification of existing solutions
  • Use of inheritance
  • Off-the-shelf components and additional solution
  • Design patterns
  • 2. Interface specification
  • Describes precisely each class interface
  • 3. Object model restructuring
  • Transforms the object design model to improve its
    understandability and extensibility
  • 4. Object model optimization
  • Transforms the object design model to address
    performance criteria such as response time or
    memory utilization.

Object Design lectures
Mapping Models to Code lecture
Outline of Today
  • Reuse Concepts
  • The use of inheritance
  • Implementation vs Interface Inheritance
  • Delegation
  • Components
  • Documenting the Object Design
  • JavaDoc

Reuse Concepts
  • Application objects versus solution objects
  • Specification inheritance and implementation
  • The Liskov Substitution Principle
  • Delegation (Section 8.3.3)
  • Delegation and inheritance in design patterns

Application domain vs solution domain objects
  • Application objects, also called domain objects,
    represent concepts of the domain that are
    relevant to the system.
  • They are identified by the application domain
    specialists and by the end users.
  • Solution objects represent concepts that do not
    have a counterpart in the application domain,
  • They are identified by the developers
  • Examples Persistent data stores, user interface
    objects, middleware.

Application Domain vs Solution Domain Objects
Requirements Analysis (Language of
Application Domain)
Object Design (Language of Solution Domain)
Incident Report
Incident Report
Text box
Implementation of Application Domain Classes
  • New objects are often needed during object
  • The use of design patterns introduces new
  • The implementation of algorithms may necessitate
    objects to hold values
  • New low-level operations may be needed during the
    decomposition of high-level operations
  • Example The EraseArea() operation in a drawing
  • Conceptually very simple
  • Implementation
  • Area represented by pixels
  • Repair () cleans up objects partially covered by
    the erased area
  • Redraw() draws objects uncovered by the erasure
  • Draw() erases pixels in background color not
    covered by other objects

Observation about Modeling of the Real World
  • Gamma et al 94
  • Strict modeling of the real world leads to a
    system that reflects todays realities but not
    necessarily tomorrows.
  • There is a need for reusable and flexible
  • Design knowledge complements application domain
    knowledge and solution domain knowledge.

The use of inheritance
  • Inheritance is used to achieve two different
  • Description of Taxonomies
  • Interface Specification
  • Identification of taxonomies
  • Used during requirements analysis.
  • Activity identify application domain objects
    that are hierarchically related
  • Goal make the analysis model more understandable
  • Service specification
  • Used during object design
  • Activity
  • Goal increase reusability, enhance modifiability
    and extensibility
  • Inheritance is found either by specialization or

Metamodel for Inheritance
  • Inheritance is used during analysis and object

Object Design
Analysis activity
Taxonomy Example
Implementation Inheritance
  • A very similar class is already implemented that
    does almost the same as the desired class

  • Example I have a List class, I need a Stack
    class. How about subclassing the Stack class
    from the List class and providing three methods,
    Push() and Pop(), Top()?

Already implemented
  • Problem with implementation inheritance
  • Some of the inherited operations might exhibit
    unwanted behavior. What happens if the Stack user
    calls Remove() instead of Pop()?

Implementation Inheritance vs Interface
  • Implementation inheritance
  • Also called class inheritance
  • Goal Extend an applications functionality by
    reusing functionality in parent class
  • Inherit from an existing class with some or all
    operations already implemented
  • Interface inheritance
  • Also called subtyping
  • Inherit from an abstract class with all
    operations specified, but not yet implemented

Delegation as alternative to Implementation
  • Delegation is a way of making composition (for
    example aggregation) as powerful for reuse as
  • In Delegation two objects are involved in
    handling a request
  • A receiving object delegates operations to its
  • The developer can make sure that the receiving
    object does not allow the client to misuse the
    delegate object

Delegates to
Delegation instead of Implementation Inheritance
  • Inheritance Extending a Base class by a new
    operation or overwriting an operation.
  • Delegation Catching an operation and sending it
    to another object.
  • Which of the following models is better for
    implementing a stack?

Comparison Delegation vs Implementation
  • Delegation
  • Pro
  • Flexibility Any object can be replaced at run
    time by another one (as long as it has the same
  • Con
  • Inefficiency Objects are encapsulated.
  • Inheritance
  • Pro
  • Straightforward to use
  • Supported by many programming languages
  • Easy to implement new functionality
  • Con
  • Inheritance exposes a subclass to the details of
    its parent class
  • Any change in the parent class implementation
    forces the subclass to change (which requires
    recompilation of both)

Lecture on Design Patterns
  • Many design patterns use a combination of
    inheritance and delegation

Component Selection
  • Select existing
  • off-the-shelf class libraries
  • frameworks or
  • components
  • Adjust the class libraries, framework or
  • Change the API if you have the source code.
  • Use the adapter or bridge pattern if you dont
    have access
  • Architecture Driven Design

  • Look for existing classes in class libraries
  • JSAPI, JTAPI, ....
  • Select data structures appropriate to the
  • Container classes
  • Arrays, lists, queues, stacks, sets, trees, ...
  • It might be necessary to define new internal
    classes and operations
  • Complex operations defined in terms of
    lower-level operations might need new classes and

  • A framework is a reusable partial application
    that can be specialized to produce custom
  • Frameworks are targeted to particular
    technologies, such as data processing or cellular
    communications, or to application domains, such
    as user interfaces or real-time avionics.
  • The key benefits of frameworks are reusability
    and extensibility.
  • Reusability leverages of the application domain
    knowledge and prior effort of experienced
  • Extensibility is provided by hook methods, which
    are overwritten by the application to extend the
  • Hook methods systematically decouple the
    interfaces and behaviors of an application domain
    from the variations required by an application in
    a particular context.

Classification of Frameworks
  • Frameworks can be classified by their position in
    the software development process.
  • Frameworks can also be classified by the
    techniques used to extend them.
  • Whitebox frameworks
  • Blackbox frameworks

Frameworks in the Development Process
  • Infrastructure frameworks aim to simplify the
    software development process
  • System infrastructure frameworks are used
    internally within a software project and are
    usually not delivered to a client.
  • Middleware frameworks are used to integrate
    existing distributed applications and components.
  • Examples MFC, DCOM, Java RMI, WebObjects,
    WebSphere, WebLogic Enterprise Application BEA.
  • Enterprise application frameworks are application
    specific and focus on domains
  • Example domains telecommunications, avionics,
    environmental modeling, manufacturing, financial
    engineering, enterprise business activities.

White-box and Black-Box Frameworks
  • Whitebox frameworks
  • Extensibility achieved through inheritance and
    dynamic binding.
  • Existing functionality is extended by subclassing
    framework base classes and overriding predefined
    hook methods
  • Often design patterns such as the template method
    pattern are used to override the hook methods.
  • Blackbox frameworks
  • Extensibility achieved by defining interfaces for
    components that can be plugged into the
  • Existing functionality is reused by defining
    components that conform to a particular interface
  • These components are integrated with the
    framework via delegation.

Class libraries and Frameworks
  • Class Libraries
  • Less domain specific
  • Provide a smaller scope of reuse.
  • Class libraries are passive no constraint on
    control flow.
  • Framework
  • Classes cooperate for a family of related
  • Frameworks are active affect the flow of
  • In practice, developers often use both
  • Frameworks often use class libraries internally
    to simplify the development of the framework.
  • Framework event handlers use class libraries to
    perform basic tasks (e.g. string processing, file
    management, numerical analysis. )

Components and Frameworks
  • Components
  • Self-contained instances of classes
  • Plugged together to form complete applications.
  • Blackbox that defines a cohesive set of
  • Can be used based on the syntax and semantics of
    the interface.
  • Components can even be reused on the binary code
  • The advantage is that applications do not always
    have to be recompiled when components change.
  • Frameworks
  • Often used to develop components
  • Components are often plugged into blackbox

Example Framework for Building Web Applications
Documenting the Object Design The Object Design
Document (ODD)
  • Object design document
  • Same as the Requirements Analysis Document (RAD)
  • additions to object, functional and dynamic
    models (from solution domain)
  • navigational map for object model
  • Javadoc documentation for all classes
  • ODD Management issues
  • Update the system models in the RAD?
  • Should the ODD be a separate document?
  • Who is the target audience for these documents
    (Customer, developer?)
  • If time is short Focus on the Navigational Map
    and Javadoc documentation?
  • ODD Template
  • http//www.oose.org

Documenting Object Design ODD Conventions
  • Each subsystem in a system provides a service
    (see Chapters on System Design)
  • Describes the set of operations provided by the
  • Specifying a service operation as
  • Signature Name of operation, fully typed
    parameter list and return type
  • Abstract Describes the operation
  • Pre Precondition for calling the operation
  • Post Postcondition describing important state
    after the execution of the operation
  • Use JavaDoc for the specification of service

  • Add documentation comments to the source code.
  • A doc comment consists of characters between /
    and /
  • When JavaDoc parses a doc comment, leading
    characters on each line are discarded. First,
    blanks and tabs preceding the initial
    characters are also discarded.
  • Doc comments may include HTML tags
  • Example of a doc comment
  • /
  • This is a ltbgt doc lt/bgt comment
  • /

More on JavaDoc
  • Doc comments are only recognized when placed
    immediately before class, interface, constructor,
    method or field declarations.
  • When you embed HTML tags within a doc comment,
    you should not use heading tags such as lth1gt and
    lth2gt, because JavaDoc creates an entire
    structured document and these structural tags
    interfere with the formatting of the generated
  • Class and Interface Doc Tags
  • Constructor and Method Doc Tags

Class and Interface Doc Tags
  • _at_author name-text
  • Creates an Author entry.
  • _at_version version-text
  • Creates a Version entry.
  • _at_see classname
  • Creates a hyperlink See Also classname
  • _at_since since-text
  • Adds a Since entry. Usually used to specify
    that a feature or change exists since the release
    number of the software specified in the
  • _at_deprecated deprecated-text
  • Adds a comment that this method can no longer be
    used. Convention is to describe method that
    serves as replacement
  • Example _at_deprecated Replaced by setBounds(int,
    int, int, int).

Constructor and Method Doc Tags
  • Can contain _at_see tag, _at_since tag, _at_deprecated as
    well as
  • _at_param parameter-name description
  • Adds a parameter to the "Parameters" section. The
    description may be continued on the next line.
  • _at_return description
  • Adds a "Returns" section, which contains the
    description of the return value.
  • _at_exception fully-qualified-class-name description
  • Adds a "Throws" section, which contains the name
    of the exception that may be thrown by the
    method. The exception is linked to its class
  • _at_see classname
  • Adds a hyperlink "See Also" entry to the method.

Example of a Class Doc Comment
  • /
  • A class representing a window on
    the screen.
  • For example
  • ltpregt
  • Window win new
  • win.show()
  • lt/pregt
  • _at_author Sami Shaio
  • _at_version I, G
  • _at_see java.awt.BaseWindow
  • _at_see java.awt.Button
  • /
  • class Window extends BaseWindow
  • ...

Example of a Method Doc Comment
  • /
  • Returns the character at the
    specified index. An index
  • ranges from ltcodegt0lt/codegt
    to ltcodegtlength() - 1lt/codegt.
  • _at_param index the index
    of the desired character.
  • _at_return the desired
  • _at_exception
  • if the index is
    not in the range ltcodegt0lt/codegt
  • to
  • _at_see
  • /
  • public char charAt(int index)
  • ...

Example of a Field Doc Comment
  • A field comment can contain only the _at_see, _at_since
    and _at_deprecated tags
  • /
  • The X-coordinate of the
  • _at_see window1
  • /
  • int x 1263732

Example Specifying a Service in Java
  • / Office is a physical structure in a building.
    It is possible to create an instance of a office
    add an occupant get the name and the number of
    occupants /
  • public class Office
  • / Adds an occupant to the office /
  • _at_param NAME name is a nonempty string /
  • public void AddOccupant(string name)
  • / _at_Return Returns the name of the office.
    Requires, that Office has been initialized with a
    name /
  • public string GetName()
  • ....

Package it all up
  • Pack up design into discrete physical units that
    can be edited, compiled, linked, reused
  • Construct physical modules
  • Ideally use one package for each subsystem
  • System decomposition might not be good for
  • Two design principles for packaging
  • Minimize coupling
  • Classes in client-supplier relationships are
    usually loosely coupled
  • Large number of parameters in some methods mean
    strong coupling (gt 4-5)
  • Avoid global data
  • Maximize cohesion
  • Classes closely connected by associations gt same

Packaging Heuristics
  • Each subsystem service is made available by one
    or more interface objects within the package
  • Start with one interface object for each
    subsystem service
  • Try to limit the number of interface operations
  • If the subsystem service has too many operations,
    reconsider the number of interface objects
  • If you have too many interface objects,
    reconsider the number of subsystems
  • Difference between interface objects and Java
  • Interface object Used during requirements
    analysis, system design and object design.
    Denotes a service or API
  • Java interface Used during implementation in
    Java (A Java interface may or may not implement
    an interface object)

  • Object design closes the gap between the
    requirements and the machine.
  • Object design is the process of adding details to
    the requirements analysis and making
    implementation decisions
  • Object design activities include
  • Identification of Reuse
  • Identification of Inheritance and Delegation
  • Component selection
  • Interface specification (next lecture)
  • Object model restructuring
  • Object model optimization
  • Object design is documented in the Object Design
    Document, which can be automatically generated
    from a specification using tools such as JavaDoc.

Additional Slides
(No Transcript)
  • Main goal
  • Reuse knowledge from previous experience to
    current problem
  • Reuse functionality already available
  • Composition (also called Black Box Reuse)
  • New functionality is obtained by aggregation
  • The new object with more functionality is an
    aggregation of existing components
  • Inheritance (also called White-box Reuse)
  • New functionality is obtained by inheritance.
  • Three ways to get new functionality
  • Implementation inheritance
  • Interface inheritance
  • Delegation

Reuse Heuristics
  • Look for existing classes in class libraries
  • JSAPI, JTAPI, ....
  • Select data structures appropriate to the
  • Container classes
  • Arrays, lists, queues, stacks, sets, trees, ...
  • Define new internal classes and operations only
    if necessary
  • Complex operations defined in terms of
    lower-level operations might need new classes and
About PowerShow.com