cs2340: ResponsibilityDriven Design - PowerPoint PPT Presentation

1 / 65
About This Presentation
Title:

cs2340: ResponsibilityDriven Design

Description:

Arbor 2000 roles/responsibilities. Responsibility Driven Design. 20 ... Arbor 2000 Architecture Conceptual, Process, Physical. Responsibility Driven Design ... – PowerPoint PPT presentation

Number of Views:72
Avg rating:3.0/5.0
Slides: 66
Provided by: joche1
Category:

less

Transcript and Presenter's Notes

Title: cs2340: ResponsibilityDriven Design


1
cs2340 Responsibility-Driven Design
  • Fall 2006

Several slides are adapted from Rebecca
Wirfs-Brock and Associates
2
Homework 3
  • Use Swiki to navigate to Spring 2003 Milestones
    page. http//coweb.cc.gatech.edu/cs2340/2714
  • Form a team of 3-4 students (Does not have to be
    final project team)
  • Due October 2 in class
  • Prepare the following artifacts to design the
    Squeaken system (M3 M5)

3
HW3 Artifacts
  • List of your brainstormed classes (5)
  • CRC Cards for your filtered classes (20)
  • Good scenarios that cover uses of the application
    (20)
  • Roles and Stereotypes identified (10)
  • Architecture (Conceptual, others if needed)(10)
  • Application and Utility classes UML Class Diagram
    (20)
  • Identify Trust Boundaries (5)
  • Each person write one contract for an object (5)
  • Give a general exception handling strategy (5)

4
From Analysis to Design
  • Refine Domain Objects with Roles and
    Responsibilities
  • Create Architecture
  • Add Application Objects
  • Add Utility Objects
  • Refine Collaborations
  • Refine Object Contracts
  • Design Exception Handling Mechanisms

5
Class Exercise Part I
  • Arbor 2000 Analysis

6
(No Transcript)
7
Goal of RDD
To move from thinking about objects as data
algorithms to thinking about objects as roles
responsibilities
8
Lets Design a Horse!!
Data-Driven Procedural Event-Driven Responsibility
-Driven
9
Responsibility-Driven Design Principles
  • Maximize Abstraction
  • Initially hide the distinction between data and
    behavior.
  • Think of objects responsibilities for knowing,
    doing,and deciding
  • Distribute Behavior
  • Promote a delegated control architecture
  • Make objects smart have them behave
    intelligently, not just hold bundles of data
  • Preserve Flexibility
  • Design objects so interior details can be readily
    changed

10
RDD Constructs
  • an application a set of interacting objects
  • an object an implementation of one or more
    roles
  • a role a set of related responsibilities
  • a responsibility an obligation to perform a
    task or know information
  • a collaboration an interaction of objects or
    roles (or both)
  • a contract an agreement outlining the terms of
    a collaboration

11
Two Ways to Think About Roles
  • Primary - Responsibilities that make an object
    unique
  • Secondary Responsibilities that allow an object
    to fit into the community of cooperating objects.

12
Role Stereotypes
  • Controller (direct activities)
  • Coordinator (delegates work)
  • Structurers (maintain relationships)
  • Information Holder (keep facts)
  • Service Provider (perform operation)
  • Interfacer (support internal/external
    communication)

13
Stereotype Examples
  • ATM Machine SessionController (Controller)
  • Word Processor FontManager (Coordinator)
  • File System Folder (Structurer)
  • Pay System Employee (Information Holder)
  • Pay System PayReport (Service Provider)
  • ATM Machine CashDispenser (Interfacer)

14
More on Roles
  • Represent how we view the object from outside
    looking in
  • Dynamic during early design
  • Use to what-if?
  • active vs. passive?
  • too many / too few responsibilities?
  • too much control?
  • Like slots (object substitution)

15
Finding Responsibilities
  • Object role stereotypes and purpose statements
  • Use cases
  • Gaps in these descriptions
  • Other requirements, themes and stories
  • Following what ifthenand how chains
  • Relationships and dependencies between candidates
  • Candidates life events
  • Technical aspects of a specific software
    environment
  • A design perspective on how things should work

16
Use Roles to Generate Responsibilities
  • Pushing on an objects character leads to initial
    responsibilities
  • Ask of a service provider, what requests should
    it handle? Turn around and state these as
    responsibilities for doing or performing
    specific services
  • Ask what duties does an interfacer have for
    translating information and requests from one
    part of the system to another (and translating
    between different levels of abstraction)?
  • What events does a controller handle and who does
    it direct?

17
Stating Responsibilities
  • A single responsibility is larger than an
    operation or attribute
  • Example A DataCollector wraps operating system
    resources, such as sockets or data streams,
    retrieves raw data and converts it (packages it)
    into one or more data records from a sensing
    device.
  • Responsibilities Receive raw data from a sensor
    or sensor group Chunks data into individual
    readings
  • Use strong descriptions. The more explicit the
    action, the stronger the statement.
  • Stronger verbs remove, merge, calculate, credit,
    activate
  • Weaker verbs organize, record, process,
    maintain, accept

18
Technique Seeing at differentabstract levels
  • We can see objects and behavior at different
    levels
  • At the conceptual (domain) level- a set of
    responsibilities
  • At the specification level- set of methods that
    can be invoked
  • At the implementation level- code and data

19
Class Exercise Part 2
  • Arbor 2000 roles/responsibilities

20
(No Transcript)
21
From Analysis to Design
  • Refine Domain Objects with Roles and
    Responsibilities
  • Create Architecture
  • Add Application Objects
  • Add Utility Objects
  • Refine Collaborations
  • Refine Object Contracts
  • Design Exception Handling Mechanisms

22
Software Architecture
  • A part of the overall Systems Architecture
  • A software architecture for a program or
    computing system consists of the structure or
    structures of that system, which comprise
    elements, the externally visible properties of
    those elements, and the relationships among them
    Bass 03.
  • The quality attributes of a software system, such
    as performance, modifiability, and security, are
    bound up in its software architecture. A system
    with the wrong architecture will be a failure.
  • Software Engineering Institute (SEI)

23
Architectural Views
  • A view is a representation of a set of system
    elements and the relations associated with them.
    Views are representations of the many system
    structures present simultaneously in software
    systems.

24
Standard Views
  • Conceptual / Logical
  • Process
  • Physical
  • Module
  • User Interaction
  • Security
  • Performance

25
Architectural Styles
  • A style is a specialization of element types
    (e.g., client, layer) and relationship types
    (e.g., is part of, request-reply connection,
    is allowed to use), along with any restrictions
    (e.g., clients interact with servers but not
    each other or all the software comprises layers
    arranged in a stack such that each layer can only
    use software in the next lower layer).

26
Common Architectural Styles
  • Client Server (thin/fat)
  • n-tier
  • Layered
  • Implicit Invocation/Event-Driven
  • Blackboard/Shared Memory
  • Pipe and Filter
  • Model View Controller

27
Layered Architecture Examples
28
Control Styles
  • Centralized
  • Dispersed
  • Delegated

29
Architectural Evaluation (Validation)
  • How do we know if we have a good architecture?
  • SAAM (Software Architecture Analysis Method)
  • ATAM (Architectural Tradeoff Analysis Method)

30
Class Exercise 3
  • Arbor 2000 Architecture Conceptual, Process,
    Physical

31

32

33

34
From Analysis to Design
  • Refine Domain Objects with Roles and
    Responsibilities
  • Create Architecture
  • Add Application Objects
  • Add Utility Objects
  • Refine Collaborations
  • Refine Object Contracts
  • Design Exception Handling Mechanisms

35
Application Objects
  • Domain Objects are familiar to the domain of
    study, recognizable to customer/user.
  • Application Objects are familiar to developers
    (UI, DB, Drivers, etc.)
  • Utility Objects are familiar to implementers
    (Data Structures, Algorithms)

36
Class Exercise
  • Add Application and Utility Classes
  • Create UML Class Diagram

37

38

39
From Analysis to Design
  • Refine Domain Objects with Roles and
    Responsibilities
  • Create Architecture
  • Add Application Objects
  • Add Utility Objects
  • Refine Collaborations
  • Refine Object Contracts
  • Design Exception Handling Mechanisms

40
Collaboration
  • Trusted and Untrusted

41
Untrusted Collaborations
  • If a collaborator cant be trusted, it doesnt
    mean it is inherently more unreliable. It may
    require extra precautions
  • Pass along a copy of data instead of sharing it
  • Check on conditions after the request completes
  • Employ alternate strategies when a request fails
  • Check for timeliness, relevance and correctly
    formed data.

42
Class Exercise
  • Define Trust Regions on your architecture

43
From Analysis to Design
  • Refine Domain Objects with Roles and
    Responsibilities
  • Create Architecture
  • Add Application Objects
  • Add Utility Objects
  • Refine Collaborations
  • Refine Object Contracts
  • Design Exception Handling Mechanisms

44
Contracts
  • The ways in which a given client can interact
    with a given server are described by a contract.
    A contract is the list of requests that a client
    can make of a server. Both must fulfill the
    contract the client by making only those
    requests the contract specifies, and the server
    by responding appropriately to those requests.
    For each such request, a set of signatures
    serves as the formal specification of the
    contract.
  • Wirfs-Brock, Wilkerson Wiener

45
Detailed Contracts
  • Defining a precondition and a postcondition for
    a routine is a way to define a contract that
    binds the routine and its callers.
  • Bertrand Meyer, Object-Oriented
    Software Construction
  • Meyers contracts add even more details. They
    specify
  • Obligations required of the client
  • Conditions that must be true before the service
    will be requested
  • Obligations required of the service provider
  • Conditions that must be true during and after the
    execution of the service
  • Guarantees of service
  • Defined for each method or service call

46
Example A Contract For A Request That Spans A
Trust Boundary
47
Class Exercise
  • Define Object Contracts

48

49
From Analysis to Design
  • Refine Domain Objects with Roles and
    Responsibilities
  • Create Architecture
  • Add Application Objects
  • Add Utility Objects
  • Refine Collaborations
  • Refine Object Contracts
  • Design Exception Handling Mechanisms

50
Exceptions and Reliability
51
Exceptions and Design
52
A range of acceptable exposure
  • Loss of comfort
  • Loss of discretionary money
  • Loss of essential money
  • Loss of life
  • Alistair Cockburn

53
Design for Exceptions
  • Focus on making design resilient. ID key
    collaborations
  • Develop consistent collaboration styles. Develop
    an application-wide policy
  • Consider exceptions early!
  • Develop trust regions in your design
  • Develop control centers, reporting and recovery
    strategies
  • Simplify your programming. Reduce exception
    handling clutter.

54
Exceptions vs. Errors
  • Exceptions are deviations from the norm that we
    expect. We try to get the application in a
    predictable state and continue on.
  • Errors are when things go unexpectedly wrong.
    Little can be done to recover.

55
More Complications
  • Consider the user steering our application.
    They try to make an order, but it is partially
    out of stock.
  • split order
  • wait till all in-stock
  • cancel order
  • modify order
  • This might potentially put system in unexpected
    state.
  • Sometimes we dont want user steering system.

56
Exception Handling Design
  • There are many different ways to handle an
    exception. It could be logged and re-thrown
    (possibly more than once), until some object
    takes corrective action.
  • Who naturally might handle exceptions?
  • External interfacers often take responsibility
    for handling faulty conditions in other systems
  • The initial requestor
  • As a fallback, pass the buck to some object who
    takes responsibility for controlling the action
  • Handle as close to problem as possible

57
Design Guidelines
  • Use exceptions to represent emergencies
  • Handle exceptions as close to the problem as
    possible
  • Separate concerns (normal vs. exception)
  • DRY principle
  • Get enough information so handlers can make
    informed decisions
  • Consistency

58
Design Guidelines
  • Avoid creating many different exception classes.
    Create only if handling expected to change
    dramatically.
  • Pass enough information with exception so that
    handlers can try to recover.
  • Handle exceptions dont let them fly anywhere
  • Raise when the object cannot fulfill contract

59
Recovery
60
Strategies
  • Inaction Do nothing
  • Balk Admit defeat
  • Guarded Suspension Suspend execution until
    conditions are OK to continue
  • Provisional Action Pretend to perform the
    action, but dont commit until conditions are OK.

61
Strategies
  • Recovery Perform and acceptable alternative
  • Rollback Try to perform, but on failure undo
    everything
  • Retry Repeatedly attempt, after recovering from
    failed attempts
  • Appeal to higher authority Allow user to steer
    application
  • Resign Minimize damage, write to log, signal
    definite and safe failure.
  • Controller objects frequently make good handling
    choices

62
Exceptions to try and anticipate
  • Users entering bad information or not responding
    at all.
  • Invalid information
  • Unauthorized or untimely requests
  • Dropped communications
  • Equipment failure
  • Corrupt data, bad files
  • Failure to complete in timely manner
  • Critical performance errors

63
Analyzing Exceptions
64
Class Exercise
  • Define Exception and Recovery Strategy

65
Class Exercise
  • Create UML Class Diagram
Write a Comment
User Comments (0)
About PowerShow.com