Software architecture quiz 10
Contract
A lawful agreement between two parties in which both parties accept obligations and on which both parties can found their rights
Behavioral patterns
Allow a choice between alogirthms and the assignment responsibilites to objects, characterize complex control flows that are difficult to follow at runtime
Adapter pattern(wrapper)
Connects incompatible components Converts the interface of one component into another interface expected by the other (calling) component used to provide a new interface to existing legacy components(Interface engineering, reengineering_
Invariant
Contract constraint: a predicate that is always true for all instances of a class
Preconditions('rights')
Contract constraint: must be true before an operation is invoked
Contracts and formal specification
Contracts enable the caller and the provider to share the same assumptions about the class contract is an exact specification of the interface of an object
Object design
Decide where to put these operations in the object model, the process of adding details to the requirements analysis and making implementation decisions, serves as the basis of implementation
Object oriented contract
Describes the services that are provided by an object if certain conditions are fulfilled,specifies conditons under which the service will be provided, a specification of the result of the service
Strategy pattern
Different algorithms exist for a specific task and we can switch between algorithms at runtime as we need them, if needed, we can add a new algorithm without disturbing the application or the other alogirthms
Facade
Given a simulation of a mouse a maze, enable the path evaluation component to evaluate different paths independently of the types of moves considered by the mouse.
Do not apply an operation to the result of another operation
Information hiding design principles: Write a new operation that combines the two operations
Only the operations of a class are allowed to manipulate its attributes
Information hiding design principles: Access attributes only via operation
Hide external objects at subsystem boundary
Information hiding design principles: Define abstract class interfaces which mediate between the external world and the system as well as between subsystems.
Trade-off: Information hiding v. efficiency
Information hiding heuristics: Accessing a private attribute might be too slow
Always apply the 'need to know principle'
Information hiding heuristics: only if somebody needs to access the information, make it publicly possible, provide only well defined channels so you always know the access
The fewer details a class user has to know
Information hiding heuristics: The easier the class can be changed and the less likely they will be affected by any changes in the class implementation
Reuse
Object design activity 1 The identification of existing solutions with use of inheritance, off the shelf components and additional solution objects, use of design patterns
Interface specification
Object design activity 2 Describes precisely each class interface
Object model restructuring
Object design activity 3 Transforms the object design model to improve its understandability and extensability
Object model optimization
Object design activity 4 Transforms the object design model to address performance criteria such as response time or memory utilization
Bridge pattern
Provides a bridge between the abstraction in the application domain and the implementor in the solution domain, can be used to provide multiple implementations under the same interface, allows to postpone design decisions to the startup time of a system
Facade pattern
Provides a unified interface to a set of classes in a subsystem, consists of a set of public operations, each public operation is delegated to one or more operations in the classes behind the facade, defines a higher level interface that makes the subsystem easier to use, abstracts the details out
Structural patterns
Reduce coupling between two or more classes, introduce an abstract classes to enable future extension, encapsulate complex structures
adapter pattern used for
Should be used to interface existing components and legacy systems
Requirements analysis
The functional model and the dynamic model deliver operations for the object model
Formal specification
a contract in which invariants, rights and obligations in the contract are unambiguous
algorithm
a method for solving a problem using a finite sequence of well-defined instructions for solving a problem
Creational Patterns
allow to abstract from complex instatiation processes, make the system independent from the way its objects are created, composed, and represented
Abstract factory pattern
applicable for situations when independence from initialization or representation, manufacturer independence, constraints on related products, coper with upcoming change
Postcondition('obligation')
contract constraint: must be true after and operation is invoked
Pattern
describes a problem which occurs over and over again in our environment and then describes the core of the solution to that problem in such a way that you can use this solution a million times over without ever doing it the same way twice
Strategy
given a chess program, enable a monitoring component to switch planning algorithms at runtime based on the opposing player's style and response time.
Bridge
given a chess program, enable future developers to substitutes the planning algorithm that decides on the next move with a better one.
Adapter pattern
given a legacy banking application, encapsulate the existing business logic component
Carefully define the public interface for classes as well as subsystems
information hiding heuristics: For subsystems use a facade pattern if possible
Class implementor
private visibility, private attributes and operations can be accessed only by the class in which they are defined, they cannot be accessed by subclasses or other classes
Class extender
protected visibility, protected attributes/operations can be accessed by the class in which they are defined and by any descendant of the class
Class user
public visibility, public attributes/operation can be accessed by any class
Facade pattern used for
should be offered by all subsystems in a software system which provide a set of services. It delegates requests to the appropriate components within the subsystem, usually does not have to be changed when the components are changed
bridge pattern used for
should be used to interface to a set of objects with a large probability of change, when the full set of objects is not completely known at analysis or design time or when there is a chance that a subsystem or component must be replaced later after the system has been deployed and client programs use it in the field