PowerPoint Presentation

Document Sample
PowerPoint Presentation Powered By Docstoc
					              Client/Server Architecture
Often used in database systems:
  • Front-end: User application (client)
  • Back end: Database access and manipulation
    (server)
Functions performed by client:
  • Customized user interface
  • Front-end processing of data
  • Initiation of server remote procedure calls
  • Access to database server across the network


 February 16, 2012   CS410 – Software Engineering   1
                       Lecture #8: Object Design
              Client/Server Architecture

Functions performed by the database server:
  • Centralized data management
  • Data integrity and database consistency
  • Database security
  • Concurrent operations (multiple user access)
  • Centralized processing (for example archiving)




 February 16, 2012   CS410 – Software Engineering   2
                       Lecture #8: Object Design
Design Goals for Client/Server Systems
Portability:
   • Server can be installed on a variety of machines
     and operating systems and functions in a variety
     of networking environments
Transparency:
   • The server might itself be distributed, but should
     provide a single "logical" service to the user
Performance:
   • Client should be customized for interactive
     display-intensive tasks
   • Server should provide CPU-intensive operations

  February 16, 2012   CS410 – Software Engineering   3
                        Lecture #8: Object Design
Design Goals for Client/Server Systems
Scalability:
   • Server has spare capacity to handle larger
     number of clients
Flexibility:
   • Should be usable for a variety of user interfaces
Reliability:
   • System should survive individual node and/or
     communication link problems



  February 16, 2012   CS410 – Software Engineering   4
                        Lecture #8: Object Design
Problems with Client/Server Architectures

• Client/server systems do not provide peer-to-peer
  communication
• Peer-to-peer communication is often needed
• Example: Database receives queries from
  application but also sends notifications to
  application when data have changed




   February 16, 2012   CS410 – Software Engineering   5
                         Lecture #8: Object Design
                Peer-to-Peer Architecture
• Generalization of Client/Server Architecture
• Clients can be servers and servers can be clients
• More difficult because of possibility of deadlocks
                                                 *   requester
                             Peer


                           service1()
                           service2()            *
                            …                        provider
                           serviceN()



   application1:DBUser       1. updateData

                                                          database:DBMS

     application2:DBUser       2. changeNotification


  February 16, 2012        CS410 – Software Engineering                   6
                             Lecture #8: Object Design
                   Repository Architecture
• Subsystems access and modify data from a single
  data structure
• Subsystems are loosely coupled (interact only
  through the repository)
• Control flow is dictated by central repository
  (triggers) or by the subsystems (locks,
  synchronization primitives)

                                                         Repository

              Subsystem
                                                  createData()
                                                  setData()
                                                  getData()
                                                  searchData()


   February 16, 2012      CS410 – Software Engineering                7
                            Lecture #8: Object Design
    Examples of Repository Architecture
                       Compiler

                                                  SemanticAnalyzer
                       SyntacticAnalyzer
                                                                       Optimizer

                   LexicalAnalyzer                                   CodeGenerator


                                          Repository
Hearsay II speech
understanding system                          ParseTree              SymbolTable
(“Blackboard architecture”)
Database Management
Systems                                 SourceLevelDebugger            SyntacticEditor
Modern Compilers

   February 16, 2012              CS410 – Software Engineering                     8
                                    Lecture #8: Object Design
    Model/View/Controller Architecture
Subsystems are classified into 3 different types
• Model subsystem: Responsible for application
  domain knowledge
• View subsystem: Responsible for displaying
  application domain objects to the user
• Controller subsystem: Responsible for
  sequence of interactions with the user and
  notifying views of changes in the model.




 February 16, 2012   CS410 – Software Engineering   9
                       Lecture #8: Object Design
     Model/View/Controller Architecture
MVC is a special case of a repository architecture:
• Model subsystem implements the central data
  structure; the Controller subsystem explicitly
  dictates the control flow

                                 initiator
              Controller
                                 *                          1   repository
                                                            Model
                                                            1   notifier
                                      subscriber
                      View
                                      *




  February 16, 2012          CS410 – Software Engineering                    10
                               Lecture #8: Object Design
                        Sequence of Events


2.User types new filename

                 :Controller               3. Request name change in model


                    1. Views subscribe to event                 :Model


                   :InfoView                               4. Notify subscribers
 5. Update views
                                   :FolderView




    February 16, 2012           CS410 – Software Engineering                       11
                                  Lecture #8: Object Design
                       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: We iterate on where to put these
operations in the object model.
Object Design serves as the basis of implementation.
   February 16, 2012    CS410 – Software Engineering   12
                          Lecture #8: Object Design
      Object Design: Closing the Gap
       System                                                 Problem
    Application objects


                                                         Requirements gap

      Solution objects

             Custom objects


                                                        Object design gap

         Off-the-shelf components



                                                        System design gap

February 16, 2012             CS410 – Software Engineering
                                Lecture #8: Object Design
                                                             Machine    13
                        Object Design Issues

•   Full definition of associations
•   Full definition of classes
•   Choice of algorithms and data structures
•   Detection of new application-domain
    independent classes (example: Cache)
•   Optimization
•   Increase of inheritance
•   Decision on control
•   Packaging

    February 16, 2012       CS410 – Software Engineering   14
                              Lecture #8: Object Design
                 Terminology of Activities

Object-Oriented Methodologies:
• System Design
        Decomposition into subsystems
• Object Design
        Implementation language chosen
        Data structures and algorithms chosen




  February 16, 2012    CS410 – Software Engineering   15
                         Lecture #8: Object Design
                 Terminology of Activities
Structured Analysis/Structured Design uses
different terminology:
 • Preliminary Design
        Decomposition into subsystems
        Data structures are chosen
• Detailed Design
        Algorithms are chosen
        Data structures are refined
        Implementation language is chosen
        Typically in parallel with preliminary design, not
         separate stage


  February 16, 2012     CS410 – Software Engineering          16
                          Lecture #8: Object Design
                   Object Design Activities
1. Service specification
 • Describes precisely each class interface
2. Component selection
 • Identify off-the-shelf components and additional
   solution objects
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.
   February 16, 2012     CS410 – Software Engineering   17
                           Lecture #8: Object Design
                       Service Specification
Requirements analysis:
• Identifies attributes and operations without
   specifying their types or their parameters.

Object design:
• Add visibility information
• Add type signature information
• Add contracts



   February 16, 2012       CS410 – Software Engineering   18
                             Lecture #8: Object Design
                       Add Visibility
UML defines three levels of visibility:
Private:
 • A private attribute can be accessed only by the class in
   which it is defined.
 • A private operation can be invoked only by the class in
   which it is defined.
 • Private attributes and operations cannot be accessed by
   subclasses or other classes.
Protected:
 • A protected attribute or operation can be accessed by the
   class in which it is defined and on any descendent of the
   class.
Public:
 • A public attribute or operation can be accessed by any
   class.
   February 16, 2012   CS410 – Software Engineering      19
                         Lecture #8: Object Design
             Information Hiding Heuristics
Build firewalls around classes.
 • Carefully define public interfaces for classes as well
   as subsystems
Apply “Need to know” principle. The fewer an
operation knows
 • the less likely it will be affected by any changes,
 • the easier the class can be changed
Trade-off:
 • Information hiding vs efficiency


   February 16, 2012   CS410 – Software Engineering   20
                         Lecture #8: Object Design
    Information Hiding Design Principles
Only the operations of a class are allowed to
manipulate its attributes.
 • Access attributes only via operations.
Hide external objects at subsystem boundary.
 • Define abstract class interfaces which mediate
   between system and external world as well as
   between subsystems.
Do not apply an operation to the result of another
operation.
 • Write a new operation that combines the two
   operations.

   February 16, 2012   CS410 – Software Engineering   21
                         Lecture #8: Object Design
                        Contracts
Contracts on a class enable caller and callee to share
the same assumptions about the class.
Contracts include three types of constraints:
• Invariant: A predicate that is always true for all
instances of a class. Invariants are constraints
associated with classes or interfaces. Invariants are
used to specify consistency constraints among class
attributes.



   February 16, 2012   CS410 – Software Engineering   22
                         Lecture #8: Object Design
                       Contracts
• Precondition: A predicate that must be true before
  an operation is invoked. Preconditions are
  associated with a specific operation. Preconditions
  are used to specify constraints that a caller must
  meet before calling an operation.
• Postcondition: A predicate that must be true after
  an operation is invoked. Postconditions are
  associated with a specific operation. Postconditions
  are used to specify constraints that the object must
  ensure after the invocation of the operation.


  February 16, 2012   CS410 – Software Engineering   23
                        Lecture #8: Object Design
                   Object Design Activities
1. Service specification
 • Describes precisely each class interface
2. Component selection
 • Identify off-the-shelf components and additional
   solution objects
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.
   February 16, 2012     CS410 – Software Engineering   24
                           Lecture #8: Object Design
                       Component Selection
Select existing off-the-shelf class libraries, frameworks
or components and adjust them:
 • Change the API if you have the source code.
 • Use the adapter or bridge pattern if you do not have
    access




   February 16, 2012       CS410 – Software Engineering   25
                             Lecture #8: Object Design
                          Reuse...
Look for existing classes in class libraries
Select data structures appropriate to the algorithms
 • 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 operations



   February 16, 2012   CS410 – Software Engineering   26
                         Lecture #8: Object Design
                   Object Design Activities
1. Service specification
 • Describes precisely each class interface
2. Component selection
 • Identify off-the-shelf components and additional
   solution objects
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.
   February 16, 2012     CS410 – Software Engineering   27
                           Lecture #8: Object Design
                     Restructuring Activities

• Realizing associations

• Revisiting inheritance to increase reuse

• Revising inheritance to remove implementation
  dependencies




 February 16, 2012         CS410 – Software Engineering   28
                             Lecture #8: Object Design
                       Increase Inheritance
• Rearrange and adjust classes and operations to
  prepare for inheritance.
• Abstract common behavior out of groups of classes.
• If a set of operations or attributes are repeated in two
  classes, the classes might be special instances of a
  more general class.
• Be prepared to change a subsystem (collection of
  classes) into a superclass in an inheritance
  hierarchy.


   February 16, 2012       CS410 – Software Engineering   29
                             Lecture #8: Object Design
Building a Super Class from Several Classes

Prepare for inheritance. All operations must have
the same signature but often the signatures do not
match:
 • Some operations have fewer arguments than
   others: Use overloading.
 • Similar attributes in the classes have different
   names: Rename attribute and change all the
   operations.



  February 16, 2012   CS410 – Software Engineering   30
                        Lecture #8: Object Design
Building a Super Class from Several Classes
Abstract out the common behavior (set of
operations with same signature) and create a
superclass out of it.
Superclasses are desirable. They
 • increase modularity, extensibility and reusability
 • improve configuration management




  February 16, 2012   CS410 – Software Engineering   31
                        Lecture #8: Object Design
               Implementing Associations
Strategy for implementing associations:
• Be as uniform as possible
• Individual decision for each association
Example of uniform implementation:
• 1-to-1 association:
        Role names are treated like attributes in the classes
         and translate to references.
• 1-to-many association:
        Translate to Vector
• Qualified association:
        Translate to Hash table

  February 16, 2012    CS410 – Software Engineering        32
                         Lecture #8: Object Design
         Unidirectional 1-to-1 Association
Object design model before transformation

          ZoomInAction                                        MapArea
                          1                      1




Object design model after transformation

          ZoomInAction                                        MapArea
                                                        -zoomIn:ZoomInAction




   February 16, 2012     CS410 – Software Engineering                      33
                           Lecture #8: Object Design
          Bidirectional 1-to-1 Association
Object design model before transformation

         ZoomInAction                                        MapArea
                          1                     1




Object design model after transformation

          ZoomInAction                                       MapArea
   -targetMap:MapArea                               -zoomIn:ZoomInAction
   +getTargetMap()                                  +getZoomInAction()
   +setTargetMap(map)                               +setZoomInAction(action)




   February 16, 2012     CS410 – Software Engineering                      34
                           Lecture #8: Object Design
                       1-to-Many Association
Object design model before transformation

               Layer                                           LayerElement
                             1                      *




Object design model after transformation

               Layer                                          LayerElement
   -layerElements:Set                                   -containedIn:Layer
   +elements()                                          +getLayer()
   +addElement(le)                                      +setLayer(l)
   +removeElement(le)




   February 16, 2012        CS410 – Software Engineering                      35
                              Lecture #8: Object Design
                   Object Design Activities
1. Service specification
 • Describes precisely each class interface
2. Component selection
 • Identify off-the-shelf components and additional
   solution objects
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.
   February 16, 2012     CS410 – Software Engineering   36
                           Lecture #8: Object Design
                       Design Optimizations
Design optimizations are an important part of the
object design phase:
 • The requirements analysis model is semantically
 correct but often too inefficient if directly implemented.
Optimization activities during object design:
1. Add redundant associations to minimize access cost
2. Rearrange computations for greater efficiency
3. Store derived attributes to save computation time
As an object designer you must strike a balance
between efficiency and clarity.
 • Optimizations will make your models more obscure
   February 16, 2012       CS410 – Software Engineering   37
                             Lecture #8: Object Design
            Design Optimization Activities
1. Add redundant associations:
 • What are the most frequent operations? (Sensor
   data lookup?)
 • How often is the operation called? (30 times a
   month, every 50 milliseconds)
2. Rearrange execution order:
 • Eliminate dead paths as early as possible (Use
   knowledge of distributions, frequency of path
   traversals)
 • Narrow search as soon as possible
 • Check if execution order of loop should be reversed
3. Turn classes into attributes
   February 16, 2012   CS410 – Software Engineering   38
                         Lecture #8: Object Design
Implement Application Domain Classes
To collapse or not collapse: Attribute or
association?
Object design choices:
 • Implement entity as embedded attribute
 • Implement entity as separate class with
    associations to other classes
Associations are more flexible than attributes but
often introduce unnecessary indirection.



 February 16, 2012   CS410 – Software Engineering    39
                       Lecture #8: Object Design
Optimization Activities: Collapsing Objects

                                                          SocialSecurity
                  Person                                  ID:String




                                     Person
                             SSN:String




  February 16, 2012        CS410 – Software Engineering                    40
                             Lecture #8: Object Design
         To Collapse or not to Collapse?
Collapse a class into an attribute if the only operations
defined on the attributes are Set() and Get().




   February 16, 2012   CS410 – Software Engineering   41
                         Lecture #8: Object Design
                 Application Domain vs.
                Solution Domain Objects
 Requirements Analysis                          Object Design
(Language of Application                 (Language of Solution Domain)
        Domain)
                                                     Incident
                                                      Report
          Incident
           Report



                                    Text box              Menu   Scrollbar




 February 16, 2012         CS410 – Software Engineering                  42
                             Lecture #8: Object Design

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:0
posted:10/4/2012
language:Unknown
pages:42