detailed design notes. mechanistic design notes outline system design requirement modeling –...
TRANSCRIPT
![Page 1: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/1.jpg)
Detailed Design
NOTES
![Page 2: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/2.jpg)
Mechanistic Design
Notes
![Page 3: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/3.jpg)
Outline
System DesignRequirement Modeling – functional requirements (Use Cases)
Analysis Modeling
Structural Object Analysis – static model defining the relationships between classes (Class Diagrams, etc.)
Behavioral Object Analysis – model describing dynamic (behavioral) aspects (statecharts, etc.)
Design Modeling – design a software architecture
Architectural Design – system-wide
Mechanistic Design – inter-object
Detailed Design – intra-object
Rational Rose Real-Time (RoseRT)
![Page 4: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/4.jpg)
Design CategoriesArchitectural Design
Mechanistic Design
Detailed DesignScope: Class
Class Name
Attributes
Operations
Class
Class
Class
Class
Node
PackageTask
TaskComponent
Scope: Sets of Collaborating Classes
![Page 5: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/5.jpg)
Mechanistic Design
Describe how a small sets of objects and classes collaborate to achieve a common goal.
Discover and use patterns in an individual object collaboration; e.g., apply solutions to structurally similar problems (reification).
Optimize the analysis model against a set of design criteria.
![Page 6: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/6.jpg)
Design Criteria
Performance
Predictability
Safety
Reliability
Maintainability
Portability
Cost
![Page 7: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/7.jpg)
Patterns and Frameworks
Patterns support reuse of software architecture and mechanistic design.Patterns capture the static and dynamic structures of successful
solutions to problems that arise in a particular domain.
Frameworks support reuse of detailed design and code.
![Page 8: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/8.jpg)
Patterns
Successful solutions to many problems are derived by using patterns.
Example: Becoming a Chess MasterLearn rules and physical requirements
Learn principles of game
Study games of other masters containing patterns that must be understood and applied repeatedly.
![Page 9: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/9.jpg)
Design Patterns
Design patterns represent solutions to problems that arise when developing software solutions in a particular context.
Patterns capture dynamic and static structure and collaboration among key participants.
Patterns facilitate reuse of successful software architectures and designs.
![Page 10: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/10.jpg)
Use Case Model
![Page 11: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/11.jpg)
Target Path Planner Classes
Path planner Plans the full path, including all changes in position and velocity.
Path The plan created by the path planner.
Path segment A part of the plan, consisting of a short sequence of precisely timed rudder adjustments and changes in acceleration to adjust position and velocity.
GPS (position) sensor A sensor that determines the current position of the target.
Rudder sensor A sensor that determines current rudder position.
Rudder pump (actuator)
A pump that controls the rudder position.
Classes Roles
(etc.)
![Page 12: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/12.jpg)
Path Control Analysis Model
![Page 13: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/13.jpg)
Terms and Concepts
A class role is the behavior of a class within a specific context.
A collaboration is a set of class roles that exchange messages to achieve an overall, coordinated behavior.
A mechanism is a design pattern that applies to a society of collaborating classes.
![Page 14: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/14.jpg)
Design Patterns
Design patterns are general solutions to commonly occurring design problems; e.g., an abstraction of a collaboration.
They consist of three parts:a common problem, including a common problem context
a generalization approach to a solution
consequences (pros and cons) of the pattern
![Page 15: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/15.jpg)
Design Pattern Categories
Correctness Patterns - used to produce correct designs.
Creation Patterns - used to configure and initialize classes and objects.
Structural Patterns - used to decouple interface and implementation.
Execution (Behavioral) Patterns - used to model interaction and control.
![Page 16: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/16.jpg)
Correctness Patterns
Smart pointer: avoid problems associated with dumb pointers.
Second guess: monitor collaboration results for reasonableness.
Exception monitor: ensure that pre- and post-conditions are met.
Watchdog monitor: ensure that equipment continues to operate within an acceptable range.
![Page 17: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/17.jpg)
Smart Pointer Pattern
Problem:Pointers may be used before being initialized.
Pointers may be used after the memory they point to has been released (dangling pointers).
Memory may not be released (memory leak).
Solution: A smart pointer object can be used when a temporary pointer is called for. It uses an internal reference counter to determine whether other smart pointers are referring to the same object in memory.
![Page 18: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/18.jpg)
Smart Pointer Pattern
Consequences:A smart pointer makes the design more robust.It increases the code complexity and requires an additional level of
indirection for each pointer reference; e.g., there is a small amount of run-time overhead.
If both smart and raw pointers are applied to the same object, reference counting should be disabled.
![Page 19: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/19.jpg)
Second Guess PatternProblem: Long computations may become
erroneous due to a variety of maladies.
Solution: Two algorithms are represented, the primary one and a another (secondary) one (used as a reasonableness check).
Consequences:The secondary algorithm can be used to verify the computation
within a predefined range.
It imposes some computational overhead.
![Page 20: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/20.jpg)
Exception-Monitor PatternProblem: Exceptions must be handled to build a
safe and reliable system.
Solution: Add exception handling by adding exception safe classes:Exception
Exception Handler
Exception Monitor
Exception Log
Global Exception Handler
![Page 21: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/21.jpg)
Exception-Monitor Pattern
Consequences:The unpredictability of language-based, exception-handling
mechanisms can be removed by using the exception-monitor pattern.
Standard language mechanisms simply walk the call stack backwards.
![Page 22: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/22.jpg)
Unsafe Linear Accelerator
LinearAccelerator
BeamEmitter
(Actuator)
BeamDetector(Sensor)
Set Intensity
Start Beam
End Beam
Beam Intensity
Beam Duration
![Page 23: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/23.jpg)
Safe Linear Accelerator
LinearAccelerator
BeamEmitter
(Actuator)
BeamDetector(Sensor)
Set Intensity
Start Beam
End Beam
Beam Intensity
BeamDuration
SafetyProcessorWatchdog
StatusStart Beam, etc.
Request Status orEmergency Shutdown
Cut-OffSwitch
Off
On
Off
![Page 24: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/24.jpg)
Creation Patterns
Factory - method in a derived class creates associates; e.g., centralize the assembly of resources needed to create an object.
Builder - factory for building complex objects incrementally.
Prototype - factory for cloning new instances.
Singleton - factory for a singular instance.
![Page 25: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/25.jpg)
Structural Patterns
Adapter - translator adapts a server interface for a client.
Bridge - abstraction for binding different implementations.
Wrapper - encapsulate or simplifies the interface for a subsystem.
Proxy - one object approximates another.
![Page 26: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/26.jpg)
Adapter Pattern
Problem: Client expects a different interface.
Solution: Convert the interface of a class into another interface the client expects.
Consequences: Provides an interface that expresses the similarities of classes the
seem different.
Requires additional level of indirection.
![Page 27: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/27.jpg)
Wrapper Pattern
Problem: Need to avoid tedious, error-prone, and non-portable programming of low-level IPC mechanisms.
Solution: Encapsulate lower-level functions within a type-safe, modular, and portable class interface.
![Page 28: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/28.jpg)
Wrapper Pattern
![Page 29: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/29.jpg)
Execution Control PatternsPolicy StateState-Table State-WalkerControl-LoopReactive Control-LoopFuzzy-StateNeural Network
![Page 30: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/30.jpg)
Policy Pattern
Problem: Many classes realize the same interface, but differ in terms of how they operate internally.
Solution:The algorithm used to implement the black-box behavior is called a
policy.
Policies can be abstracted away from the main class to simplify the interface, improve reuse, and allow for dynamic choice of policies.
![Page 31: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/31.jpg)
Policy Pattern ObjectsClient - uses services and operations of the Context
object.Context - provides a context for the Abstract Policy
object, and invoke services necessary to implement the policy.
Abstract Policy - provides a virtual interface to the Concrete Policy object.
Concrete Policy- implements the algorithm and services for the selected policy.
![Page 32: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/32.jpg)
State Pattern
Problem: Many systems spend most of their time in only a few states. It is more efficient to make this part of the system more efficient; e.g., lightweight.
Solution: A composite object can manage the state behavior.
![Page 33: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/33.jpg)
State Table Pattern
Problem: Need a simple mechanism to manage large state machines efficiently.
Solution: A state table can be implemented as an n x m array wheren is the number of states, and
m is the number of transitions.
![Page 34: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/34.jpg)
Mechanistic Design Summary
Mechanistic Design - design patterns capture successful solutions for collaborating classes
More Design Patterns: http://www.cs.uiuc.edu/users/patterns/patterns.html
![Page 35: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/35.jpg)
Detailed DesignArchitectural Design
Mechanistic Design
Detailed DesignScope: Class
Class Name
Attributes
Operations
Class
Class
Class
Class
Node
PackageTask
TaskComponent
Scope: Sets of Collaborating Classes
![Page 36: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/36.jpg)
Detailed DesignAn object can be defined as “a set of tightly coupled
attributes and the operations that act on them”.
The scope of detailed design is limited to individual objects.
Detailed design specifies intra-object details; e.g., “what the man behind the curtain (in the black box) does”.
![Page 37: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/37.jpg)
Intra-Object DetailsData structuring of non-primitive attributes
Implementation of associations
Detailed definition of object interface
Finalization of operations defined for a class
Detailed design of algorithms implemented by those operations
Exceptions handled and thrown
![Page 38: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/38.jpg)
Data StructuresPrimitive Types
Subrange Constraintstypedef subrange<int, 0, 99> tWeight;
tWeight item_weight;
Derived Attributesattributes that can be reconstructed from other attributes within the
class
added to optimize performance
Data-Collection Structure
![Page 39: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/39.jpg)
Data-Collection StructureCollections of primitive data attributes can be
structured in different ways: list, stack, queue, vectors, trees, etc.
Common role constraints provided by UML{ordered} = sorted
{bag} = may have several copies of same item
{set} = only single copies of each item
{hashed} = reference via a keyed hash
{ordered set}, etc. = combinations of above
![Page 40: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/40.jpg)
AssociationsAssociations allow client objects to invoke the
operations provided by server objects.
There are many ways to implement associations.
Detailed design resolves the management of associations between the objects.
Crossing thread boundaries complicates the resolution of associations.
![Page 41: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/41.jpg)
Container Pattern ExampleMultivalued roles (1-*) are frequently resolved using the Container Pattern:
![Page 42: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/42.jpg)
Associations: Crossing Thread Boundaries
Crossing thread boundaries complicates the resolution of associations
Direct calling may not be possible
Other MechanismsMessage Queues
Pipes
Named Pipes
Network Protocols (TCP/UDP/RPC/CAN)
![Page 43: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/43.jpg)
Message Passing Patterns
Observer Pattern
Proxy Pattern
Adaptor Pattern
![Page 44: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/44.jpg)
Observer Pattern
Standard pattern for monitoring objects.This pattern sets up two types of objects:
subjects
objects
Observers register with subjects, and are notified of state changes.
Observers acknowledge to subjects when a change has been observed.
![Page 45: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/45.jpg)
Object InterfaceAn interface is a named set of operations.
An interface in the UML is an abstract notion that cannot be instantiated; interfaces are realized by eitherlogical elements (classes and packages), or
run-time artifacts (components).
Interfaces may be realized by different classes, and a single class may realize different interfaces.
![Page 46: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/46.jpg)
Definition of OperationsOperations defined by a class specify how the data may
be manipulated.Example: Queue
template <class T, int size> class queue { protected: T q[size]; int head, tail; public: queue(void): head(0), tail(0); virtual void put(T, myT); virtual T get(void); };
![Page 47: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/47.jpg)
Detailed Algorithmic Design
An algorithm is a step-by-step procedure for computing a desired result.
The complexity of an algorithm is usually measured in space and time using big-O.
O( f ) = { t(n) : t(n) <= c * f(n) for sufficiently large values of n }.
![Page 48: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/48.jpg)
Representing Algorithms in the UML
Single- and multi-threaded algorithms can be captured by the UML in several ways:Statecharts - can describe event-driven algorithms,Activity diagrams - concurrent flowcharts can depict programmatic
constructs of sequence, branch, loop, fork, and join.Sequence diagrams - don’t show concurrency well.
![Page 49: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/49.jpg)
Response Calculator Example
![Page 50: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/50.jpg)
Exceptions
In the UML, a Signal is a metaclass defined as a “specification of an asynchronous stimulus communicated between instances”.
An Exception is a specialized type of Signal that is used when the stimulus is a fault of some kind; e.g., the violation of a range invariant, etc.
![Page 51: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/51.jpg)
Exceptions (continued)An Event is a “specification of a significant occurrence
that has a location in time and space”. A SignalEvent is an Event that associates with Signal.
Signal and Operation are two kinds of Request (which are specifications of MessageInstances).
Class operations can raise (or throw) exceptions.
![Page 52: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/52.jpg)
Modeling Exceptions in the UML
![Page 53: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/53.jpg)
Language-Based Exception Handling
Two primary benefits:Exceptions cannot be ignored.Separates exception handling from the usual execution path.
if ((fp=ftest1(x,y,z)) == NULL) { try { printf(“Failure on test 1. \n”); ftest1(x,y,z); exit(1); }} catch (test1Failure& t1) {
cout << “Failure on test 1.”; throw;}
![Page 54: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/54.jpg)
Language-Based Exception Handling
Each operation must answer two questions:What exceptions should be caught? Generally, all exceptions that it has the
context to handle.
What exceptions should be thrown? Generally, all other exceptions.
Exceptions:Destructors should never throw exceptions or call operations that might
throw exceptions.
Constructors of exception classes should not throw exceptions.
![Page 55: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/55.jpg)
State-Based Exception Handling
In reactive classes, exception handling is straightforward.
Exceptions are associated with the triggering events specified in the class statechart.
Additional states are used to represent fault conditions; stereotype = <<exception>>.
![Page 56: Detailed Design NOTES. Mechanistic Design Notes Outline System Design Requirement Modeling – functional requirements (Use Cases) Analysis Modeling Structural](https://reader036.vdocuments.us/reader036/viewer/2022062807/5697c0271a28abf838cd6652/html5/thumbnails/56.jpg)
State-Based Exception Handling