Title: Chapter 12: Advanced Topics in ObjectOriented Design
1Chapter 12 Advanced Topics in Object-Oriented
Design
- Systems Analysis and Design in a Changing World,
3rd Edition
2Learning Objectives
- Explain the importance of design patterns in
object-oriented design - Briefly describe and use the singleton, adapter,
and observer design patterns - Explain why enterprise-level systems require
special design considerations
3Learning Objectives (continued)
- Apply UML physical design notation to Web-based
systems - Explain how Web services work to obtain
information on the Internet - Explain how statecharts can be used to describe
system behaviors - Use statecharts to model object and system
behaviors
4Overview
- This chapter provides OO developers with broader
understanding of systems design - Design principles and design patterns
- Designing enterprise-level systems, including
Web-based systems - Modeling system and complex object behavior, such
as user-interface objects or network objects - Unified Modeling Language (UML) includes
statechart diagram to model complex objects
5Design Principles and Design Patterns
- Object designer must identify responsibilities
for each class - Object is responsible for
- Maintaining its attributes and getting
information from other objects, as needed, to
fill in values - Creating objects that are dependents of the
object - Being an expert on needed information and/or
navigation visibility and access to other objects
that have the needed information
6Additional Design Principles
- Systems based on good design principles
- Easier to develop
- Easier to maintain
- Enhance flexibility of new system
- Protection from variations segregate system
parts unlikely to change from parts that change - Indirection decouple two classes or system
components by inserting intermediate class
7Importance of Design Patterns
- Templates and patterns are part of daily life
- Patterns are created to solve common problems
- Two standard design templates
- Use case controller
- Three-layer design
- Java and .NET use multiple enterprise patterns
8Basic Design Patterns
- Gang of Fours basic classification scheme
- Class-level patterns abstract patterns that
apply to static methods or do not instantiate
objects - Object-level patterns specify objects
instantiated from classes - Creational, Structural, Behavioral
- Singleton one instance started from one place
- Adapter plugs external class into existing
- Observer callback technique, publish/subscribe
9Pattern Description for Controller Pattern
10Classification of Design Patterns
11Singleton Pattern Template
12Adapter Pattern Template
13Three Classes in the Create New Order Use Case
14Implementation for the Observer Pattern
15Observer Pattern Template
16Designing Enterprise-Level Systems
- Shared components among multiple people or groups
in organization - Multi-tiered computers
- Client-server network based systems
- Internet-based systems
- Implementation diagram physical components of
system - Deployment diagram shows physical components
across different locations
17Differences Between Client-Server and Internet
Systems
18UML Notation for Deployment Diagrams
- Component symbol executable module
- All classes complied into single entity
- Defined interfaces, or public methods, accessible
by other programs or external devices - Application program interface (API) set of
public methods available to the outside world - Node symbol physical entity at specific
location - Frameset high-level object holds items to be
displayed by a browser
19UML Component Notation
20UML Node Notation
21UML Extension for Frameset
22Internet-Based Systems
- Implement three-layer design in Web-based
architecture - Simple Internet architecture
- Static Web pages
- Two-layer architecture for user interaction
- System responds to user requests (inputs/outputs)
- Three-layer architecture for user interaction
- Domain layer added for business logic
23Simple Internet Architecture
24Two-Layer Internet Architecture
25Three-Layer Internet Architecture
26Web Services
- Program sends out request for information
- Universal Discovery, Description, and Integration
(UDDI) services directory locates the web service - Internet address of program to provide service
- Program obtains desired information over Internet
- XML (eXtensible Markup Language) facilitates
communication through self-defining tags
27Invoking a Web Service
28Modeling System and Object Behavior
- Class diagrams used to understand program
structure and database schema - Use case diagrams and interaction diagrams
describe basic business and system processes - Statechart diagrams describe complex processes
and object behavior (similar to activity diagram) - Used for event-driven, real-time systems
- Identify states of business object and describe
way that object moves from state to state
29Statecharts for Problem Domain Classes
- Useful to design and describe internal activity,
or method logic, of system object - Pseudostate starting point of a statechart
- State condition that occurs during an objects
life when it satisfies some criteria, performs
some action, or waits for an event - Transition movement of object from one state to
another state (origin and destination) - Message event trigger for the transition
30Simple Statechart for a Printer
31Nested States and Concurrency
- Concurrency condition of being in more than one
state at a time - Path sequential set of connected states and
transitions - Composite states state containing multiple
levels and transitions - Represents a higher level of abstraction
- Can contain nested states and transition paths
- Paths are independent
32Simple Composite States for the Printer Object
33Concurrent Path for a Printer in the On State
34Rules for Developing Statecharts
- Review class diagram and select classes that
require statecharts - For each selected class in group, brainstorm to
list all status conditions you can identify - Begin building statechart fragments by
identifying transitions that cause object to
leave identifying state - Sequence these state-transition combinations in
correct order
35Rules for Developing Statecharts (continued)
- Review paths and look for independent, concurrent
paths - Look for additional transitions
- Take every pairwise combination of states and
look for valid transition between states - Expand each transition with the appropriate
message event, guard-condition, and
action-expression - Review and test each statechart
36States and Exit Transitions for OrderItem
37Partial Statechart for OrderItem
38Final Statechart for OrderItem
39States and Exit Transitions for Order
40First-Cut Statechart for Order
41Second-Cut Statechart for Order
42Statecharts as Design Models
- Describes system behaviors and constraints
- System is object, so system statechart can be
developed - Menu items, windows modality, tool bars and icons
- State variable record value of current state to
inform system which items to enable or disable
and which messages to process or ignore - Design class diagrams, sequence diagrams, and
statecharts work together to complete design
43Logon Statechart for a Computer System
44Sequence Diagram for Create New Order
45Design Class for Order
46Statechart for Order
47Summary
- Systems based on good design principles are
easier to develop and easier to maintain - Protection from variations separate components
or design elements that do not change from those
that are likely to change - Indirection to isolate changes insert
intermediate object between two linked objects
that do not have a natural interface
48Summary (continued)
- Good design based on standard design patterns
- Template or standard solution to common problem
- Singleton pattern all processing goes through
one and only one control point - Adapter pattern converts one application
program interface (API) into another API - Observer pattern allows two objects to be
linked dynamically to keep coupling low and
provide temporary communication capacity
49Summary (continued)
- Statecharts used to describe the behavior, or
life cycle, of object or of system - State condition of the object
- Transition connectors between states and permit
an object to move from state to state - Statechart diagram that identifies all states
of an object and actions that cause object to
change from state to state