Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Agenda
Agenda
Architectural Process
Where do Architectures Come From?
• All software architectures rely on two pillars:
- Creativity:
- Fun, BUT strained with risk
- May be unnecessary, BUT may render the best result
- Method
- Efficient in familiar terrain, BUT not always successful
- Predictable outcome (pros & cons), BUT quality of methods varies
Architectural Process
Objectives
• Creativity
- Enhance your skill-set
- Provide new tools
• Method
- Focus on highly effective and proven techniques
• Develop judgment:
- when to develop novel solutions
- when to follow established method
Architectural Process
Design Stages
• Feasibility stage:
- identifying a set of feasible concepts for the design as a whole
• Preliminary design stage:
- selection and development of the best concept.
• Detailed design stage:
- development of engineering descriptions of the concept.
• Refinement stage:
- evaluating and altering the concept to suit the requirements of production,
distribution, consumption and product retirement.
Architectural Process
Potential Problems
• If the designer is unable to produce a set of feasible concepts, progress stops.
• As problems and products increase in size and complexity, the probability that
any one individual can successfully perform the first steps decreases.
• The standard approach does not directly address the situation where system
design is at stake, i.e. when relationship between a set of products is at issue.
• As complexity increases or the experience of the designer is not sufficient,
alternative approaches to the design process must be adopted.
Architectural Process
Alternative Design Strategies
• Standard
• Linear model (as above)
• Cyclic
• Process can revert to an earlier stage
• Parallel
• Independent alternatives are explored in parallel
• Adaptive (“lay tracks as you go”)
• The next design strategy of the design activity is decided at the end of a
given stage
• Incremental
• Each stage of development is treated as a task of incrementally improving
the existing design
Architectural Process
Identifying a Viable Strategy
• Use fundamental design tools:
- Abstraction But
- Modularity how?
• Use:
- Inspiration, where inspiration is needed But where is
- Predictable techniques elsewhere. creativity required?
Architectural Process
The Basic Tools of Software Engineering
• Abstraction, applicable in two different ways:
- Bottom-up: look at details, and abstract “up” to concepts
- Top-down: choose concepts, then add detailed substructure, and move
“down”
• Modularity, applicable in six different ways:
- Splitting a design into two or more modules
- Substituting one design module for another
- Augmenting the system by adding a new module
- Excluding a module from the system
- Inverting a module to create new interfaces (design rules)
- Porting a module to another system
• The key design principles
Architectural Process
A Few Definitions*
• Abstraction:
- “The act or process of separating in thought, of considering a thing independently of its
associations; or a substance independently of its attributes; or an attribute or quality
independently of the substance to which it belongs.”
• Reification:
- “The mental conversion of … [an] abstract concept into a thing.”
• Deduction:
- “The process of drawing a conclusion from a principle already known or assumed;
spec. in Logic, inference by reasoning from generals to particulars; opposed to
INDUCTION.”
• Induction:
- “The process of inferring a general law or principle from the observation of particular
instances (opposed to DEDUCTION).”
Architectural Process
Abstraction and the Fundamental Machines
• What concepts should be chosen at the outset of a design task?
- One technique: Search for a “fundamental machine” that serves as an
abstraction of a potential system that will perform the required task. For
instance:
- Q: what kind of fundamental machine makes a software system
embedded in a washing machine?
- A: at core, it is basically just a little finite state machine.
• Fundamental machines provide a plausible first conception of how an application
might be built.
• Every application domain has its common fundamental machines.
Architectural Process
Fundamental Machines
Domain Fundamental Machines
Graphics Pixel arrays
Transformation matrices
Widgets
Word processing Structured documents
Layouts
Process control Finite state machines
Web pages Hypertext
Composite documents
Scientific computing Matrices
Mathematical functions
Banking Spreadsheets
Databases
Transactions
Architectural Process
Choosing the Level and Terms of Discourse
• Any attempt to use abstraction as a tool must choose a level of discourse, and
once that is chosen, must choose the terms of discourse.
- Variant 1: initial level of discourse is one of the application as a whole (step-
wise refinement).
- Variant 2: work, initially, at a level lower than that of the whole application.
- Once several such sub-problems are solved they can be composed
together to form an overall solution
- Variant 3: work, initially, at a level above that of the desired application.
- E.g. handling simple application input with a general parser.
Architectural Process
The Key Design Principles
• Separation of concerns: Break your application into distinct features that overlap in
functionality as little as possible.
• Single Responsibility Principle: Each component or a module should be responsible for
only a specific feature or functionality.
• Principle of least knowledge: A component or an object should not know about internal
details of other components or objects (also known as the Law of Demeter).
• Don’t Repeat Yourself (DRY): There should be only one component providing a specific
functionality; the functionality should not be duplicated in any other component.
• Avoid doing a big design upfront: If your application requirements are unclear, or if
there is a possibility of the design evolving over time, avoid making a large design effort
prematurely (often abbreviated as BDUF).
• Prefer composition over inheritance: Wherever possible, use composition over
inheritance when reusing functionality because inheritance increases the dependency
between parent and child classes, thereby limiting the reuse of child classes.
Architectural Process
The Grand Tool: Refined Experience
• Experience must be reflected upon and refined.
• The lessons from prior work include not only the lessons of successes, but also
the lessons arising from failure.
• Learn from success and failure of other engineers
- Literature
- Conferences
- Networking
• Experience can provide that initial feasible set of “alternative arrangements for
the design as a whole”.
Agenda
Refined Experience
Patterns, Styles, and DSSAs
Refined Experience
Domain-Specific Software Architectures*
• A DSSA is an assemblage of software components
- specialized for a particular type of tasks (domain),
- generalized for effective use across that domain,
- composed in a standardized structure (topology) effective for building
successful applications.
• Since DSSAs are specialized for a particular domain they are only of value if one
exists for the domain wherein the engineer is tasked with building a new
application.
• DSSAs are the pre-eminent means for maximal reuse of knowledge and prior
development and hence for developing a new architectural design.
Source: http://www.sei.cmu.edu/pub/documents/92.reports/pdf/sr09.92.pdf
Refined Experience
Architectural Patterns
• An architectural pattern is a set of architectural design decisions that are
applicable to a recurring design problem, and parameterized to account for
different software development contexts in which that problem appears.
• Architectural patterns are similar to DSSAs but applied “at a lower level” and
within a much narrower scope.
Refined Experience
State-Logic-Display: Three-Tiered Pattern
• Application Examples
- Business applications
- Multi-player games
- Web-based applications
Refined Experience
Model-View-Controller (MVC)
• Objective: Separation between information, presentation and user interaction.
• When a model object value changes, a notification is sent to the view and to the controller.
- Thus, the view can update itself and the controller can modify the view if its logic so
requires.
• When handling input from the user the windowing system sends the user event to the
controller.
- If a change is required, the controller updates the model object.
View
Graphical (Encapsulation of
display display choices)
Model
(Encapsulation
of information)
Controller
(Encapsulation of
UI events interaction
semantics)
Refined Experience
Architectural Styles
Agenda
Architectural Styles
Definitions of Architectural Style
• Definition, in two “flavors”:
Architectural Styles
Basic Properties of Styles
• A vocabulary of design elements
- Component and connector types; data elements
- e.g., pipes, filters, objects, servers
• A set of configuration rules
- Topological constraints that determine allowed compositions of elements
- e.g., a component may be connected to at most two other components
• A semantic interpretation
- Compositions of design elements have well-defined meanings
• Possible analyses of systems built in a style
Architectural Styles
Benefits of Using Styles
• Design reuse
- Well-understood solutions applied to new problems
• Code reuse
- Shared implementations of invariant aspects of a style
• Understandability of system organization
- A phrase such as “client-server” conveys a lot of information
• Interoperability
- Supported by style standardization
• Style-specific analyses
- Enabled by the constrained design space
• Visualizations
- Style-specific depictions matching engineers’ mental models
Architectural Styles
Style Analysis Dimensions
• What is the design vocabulary (component and connector types)?
• What are the allowable structural patterns?
• What is the underlying computational model?
• What are the essential invariants of the style?
• What are common examples of its use?
• What are the (dis)advantages of using the style?
• What are the style’s specializations?
Architectural Styles
Some Common Styles
• Traditional, language-influenced styles • Interpreter
- Sequential processing - Interpreter
- Object-oriented - Mobile code
• Layered • Implicit invocation
- Virtual machines - Event-based
- Client-server - Publish-subscribe
• Data-flow styles • Peer-to-peer
- Batch sequential • “Derived” styles
- Pipes and filters - REST
• Shared memory
- CORBA
- Blackboard
- COM/DCOM
- Rule based
Architectural Styles
Sequential Processing Style
• Components are programs and libraries
- Main executable and associated dll’s
• Connectors are function invocations and corresponding parameters
• Style invariants
- There is always a main execution and control loop
• Advantages
- Simplicity
• Disadvantages
- Simplicity ☺
Architectural Styles
Sequential Processing Style
Function
library
(dll)
call/return
Function Function
library library
Executable
(dll) call/return call/return (dll)
Main Loop
call/return call/return
Function Function
library library
(dll) (dll)
Architectural Styles
Object-Oriented Style
• Components are objects
- Data and associated operations
• Connectors are messages and method invocations
• Style invariants
- Objects are responsible for their internal representation integrity
- Internal representation is hidden from other objects
• Advantages
- “Infinite malleability” of object internals
- System decomposition into sets of interacting agents
• Disadvantages
- Objects must know identities of servers
- Side effects in object method invocations
Architectural Styles
Object-Oriented Style
Procedure
“GET” Procedure Procedure call “PROCESS”
call call “SET”
Processing object
Domain object
Architectural Styles
Layered Style – 1
• Hierarchical system organization
- “Multi-level client-server”
- Each layer exposes an interface (API) to be used by above layers
• Each layer acts as a
- Server: service provider to layers “above”
- Client: service consumer of layer(s) “below”
• Connectors are protocols of layer interaction
• Virtual machine style results from fully opaque layers
Architectural Styles
Layered Style – 2
• Advantages
- Increasing abstraction levels
- Evolvability
- Changes in a layer affect at most the adjacent two layers (reuse)
- Different implementations of layer are allowed as long as interface is
preserved
- Standardized layer interfaces for libraries and frameworks
• Disadvantages
- Not universally applicable
- Performance
• Layers may have to be skipped
- Determining the correct abstraction level
Architectural Styles
Layered Style
breach
L3 bridging
Architectural Styles
Virtual Machine Style
Layer 1
Application A
Layer 2
Application B Application C
Layer 3
Application D
Architectural Styles
Client-Server Style
• Components are clients and servers
• Connectors are RPC-based network interaction protocols
• Style invariants:
- Servers do not know number or identities of clients
- Clients know server’s identity
• Advantages
- Explicit support for separation of concerns
• Disadvantages
- Lack of support for single responsibility
Architectural Styles
Client-Server Style
Procedure
Procedure
Procedure call
call
call
SERVER
Business Logic
State
Process
Architectural Styles
Data-Flow Styles
Batch Sequential
- Separate programs are executed in order; data is passed as an aggregate
from one program to the next.
- Connectors: file system tools, human operators (e.g. ConnectDirect, tapes)
- Data Elements: Explicit, aggregate elements passed from one component to
the next upon completion of the producing program’s execution.
• Typical uses: Transaction processing in financial systems. “The Grandfather of
all Styles”
Architectural Styles
Pipes and Filters Style – 1
• Components are filters
- Transform input data streams into output data streams
- Possibly incremental production of output
• Connectors are pipes
- Conduits for data streams
• Style invariants
- Filters are independent (no shared state)
- Filter has no knowledge of up- or down-stream filters
• Variations
- Pipelines — linear sequences of filters
- Bounded pipes — limited amount of data on a pipe
- Typed pipes — data strongly typed
Architectural Styles
Pipes and Filters Style – 2
• Advantages
- System behavior is a succession / composition of component behaviors
- Filter addition, replacement, and reuse (possible to hook any two filters
together)
- Certain analyses (throughput, latency, deadlock)
- Concurrent execution
• Disadvantages
- Batch organization of processing
- Interactive applications
- Lowest common denominator on data transmission
Architectural Styles
Pipes and Filters Style
Pipe Pipe
Filter
Pipe
Architectural Styles
Blackboard Style
• Two kinds of components
- Central data structure (blackboard)
- Components operating on the blackboard (agents)
• Connectors can be anything from RPC based protocols to shared memory
• Style invariants
- System control is entirely driven by the blackboard state
• Advantages
- Excellent separation of concerns and single responsibility
- Explicit process state
• Disadvantages
- Streamlining the processing
- Interactive applications
Architectural Styles
Blackboard Style
Agent 1
Agent n Agent 2
Data structure
(Blackboard)
Agent …
Architectural Styles
Rule-Based Style
Inference engine parses user input and determines whether it is a fact/rule or a
query. If it is a fact/rule, it adds this entry to the knowledge base. Otherwise, it
queries the knowledge base for applicable rules and attempts to resolve the
query.
• Components are user interface, inference engine, knowledge base
• Connectors are direct procedure calls and/or shared memory.
• Data Elements are facts and queries
• Behavior of the application can be very easily modified through addition or
deletion of rules from the knowledge base.
• Caution: When a large number of rules are involved understanding the
interactions between multiple rules affected by the same facts can become very
difficult.
Architectural Styles
Rule-Based Style
User interaction
facts/rules || queries
Procedure
call
Inference engine
Procedure
call
Knowledge base
(facts/rules)
Architectural Styles
Interpreter Style
Interpreter parses and executes input commands, updating the state
• Components are command interpreter, program/interpreter state, user interface.
• Connectors typically direct procedure calls and shared state.
• Highly dynamic behavior possible, where the set of commands is dynamically
modified. System architecture may remain constant while new capabilities are
created based upon existing primitives.
• Superb for end-user programmability; supports dynamically changing set of
capabilities
• Examples: VBScript, Jscript/ECMAScript
Architectural Styles
Interpreter Style
inputs Pseudo-code
Pseudo-code
To Be
State
Interpreted
outputs Interpretation
Interpretation Selected instructions
Engine
Engine Selected data
Control State
Architectural Styles
Mobile-Code Style
• Summary: a data element (some representation of a program) is dynamically
transformed into a data processing component.
• Components: “Execution dock”, which handles receipt of code and state; code
compiler/interpreter
• Connectors: Network protocols and elements for packaging code and data for
transmission.
• Data Elements: Representations of code as data; program state; data
• Examples: SQL Ad-hoc querying, some Reflection scenarios
Architectural Styles
Mobile-Code Style
stream
stream of code
of code stream
of code
SERVER
Architectural Styles
Implicit Invocation Style – 1
• Event announcement instead of method invocation
- “Listeners” register interest in and associate methods with events
- System invokes all registered methods implicitly
• Component interfaces are methods and events
• Two types of connectors
- Invocation is either explicit or implicit in response to events
• Style invariants
- “Announcers” are unaware of their events’ effects
- No assumption about processing in response to events
Architectural Styles
Implicit Invocation Style – 2
• Advantages
- Component reuse
- System evolution
- Both at system construction-time & run-time
• Disadvantages
- Counter-intuitive system structure
- Components relinquish computation control to the system
- No knowledge of what components will respond to event
- No knowledge of order of responses
Architectural Styles
Publish-Subscribe
Subscribers register/deregister to receive specific messages or specific content.
Publishers broadcast messages to subscribers either synchronously or
asynchronously.
• Components: Publishers, subscribers, proxies for managing distribution
• Connectors: Typically a network protocol is required. Content-based
subscription requires sophisticated connectors.
• Data Elements: Subscriptions, notifications, published information
• Topology: Subscribers connect to publishers either directly or may receive
notifications via a network protocol from intermediaries
• Qualities yielded: Highly efficient one-way dissemination of information with very
low-coupling of components
Architectural Styles
Publish-Subscribe
Subscriber 1
Subscriber 2
Event
Subscriber 3
Stream
Stream SERVER
(publisher)
Stream
Architectural Styles
Event-Based Style
• Independent components asynchronously emit and receive events
communicated over event buses
• Components: Independent, concurrent event generators and/or consumers
• Connectors: Event buses (at least one)
• Data Elements: Events – data sent as a first-class citizen over the event bus
• Topology: Components communicate with the event buses, not directly to each
other.
• Variants: Component communication with the event bus may either be push or
pull based.
• Highly scalable, easy to evolve, effective for highly distributed applications.
Architectural Styles
Event-Based Style
event event
notifications notifications
Event bus
event event
notifications notifications
Process State
Architectural Styles
Peer-to-Peer Style
• State and behavior are distributed among peers which can act as either clients
or servers.
• Peers: independent components, having their own state and control thread.
• Connectors: Network protocols, often custom.
• Data Elements: Network messages
• Topology: Network (may have redundant connections between peers); can vary
arbitrarily and dynamically
• Supports decentralized computing with flow of control and resources distributed
among peers.
• Highly robust in the face of failure of any given node.
• Scalable in terms of access to resources and computing power.
- But extremely demanding in terms of protocol’s complexity!
Architectural Styles
Peer-to-Peer Style
Application
Application
instance
instance Stream
Stream
Stream
Stream Application
instance
Application
instance Stream
Stream
Application
instance
Architectural Styles
Heterogeneous Styles
• More complex styles created through composition of simpler styles
• REST (REpresentational State Transfer)
- Focus on state transitions instead on method invocation
• Distributed objects
- CORBA, COM/DCOM
• …
Architectural Styles
REST Style
A style where the application state and functionality are abstracted into uniquely
addressable resources.
• Components: resources and clients
• Connectors: network protocol (client-server, stateless, cacheable, layered).
• Data Elements: state.
• Topology: practically every possible meshing topology imaginable.
Architectural Styles
REST Style
Resource server 1
Resource server n
Architectural Styles
Distributed Objects: CORBA, COM/DCOM
• “Objects” (coarse- or fine-grained) run on various hosts, written in heterogeneous
languages. Objects provide services through well-defined interfaces. Objects invoke
methods across host, process, and language boundaries via remote procedure calls
(RPCs).
• Components: Objects (software components exposing services through well-defined
provided interfaces)
• Connector: (Remote) Method Invocation / (Remote) Procedure Call
• Data Elements: Arguments to methods, return values, and exceptions
• Topology: General graph of objects from callers to callees.
• Additional constraints imposed: Data passed in remote procedure calls must be
serializable. Callers must deal with exceptions that can arise due to network or process
faults.
• Location, platform, and language “transparency”. CAUTION – usually does not works as
advertised! ☺
Architectural Styles
Distributed Objects: CORBA, COM/DCOM
Component server 1
Component server n
Architectural Styles
Observations
• Different styles result in
- Different architectures
- Architectures with greatly differing properties
• A style does not fully determine resulting architecture
- A single style can result in different architectures
- Considerable room for
- Individual judgment
- Variations among architects
• A style defines domain of discourse
- About problem (domain)
- About resulting system
Architectural Styles
Style Summary (1/4)
Style Category & Summary Use It When Avoid It When
Name
Language-influenced styles
Main Program and Main program controls program Application is small and simple. Complex data structures needed.
Subroutines execution, calling multiple Future modifications likely.
subroutines.
Object-oriented Objects encapsulate state and Close mapping between external entities and Application is distributed in a heterogeneous
accessing functions internal objects is sensible. network.
Many complex and interrelated data Strong independence between components
structures. necessary.
High performance required.
Layered
Virtual Machines Virtual machine, or a layer, offers Many applications can be based upon a Many levels are required (causes inefficiency).
services to layers above it single, common layer of services. Data structures must be accessed from multiple
Interface service specification resilient when layers.
implementation of a layer must change.
Client-server Clients request service from a server Centralization of computation and data at a Centrality presents a single-point-of-failure risk;
single location (the server) promotes Network bandwidth limited; Client machine
manageability and scalability; end-user capabilities rival or exceed the server’s.
processing limited to data entry and
presentation.
Architectural Styles
Style Summary (2/4)
Data-flow styles
Batch sequential Separate programs executed Problem easily formulated as a set of Interactivity or concurrency between
sequentially, with batched input sequential, severable steps. components necessary or desirable.
Random-access to data required.
Pipes-and-filters Separate programs, a.k.a. filters, [As with batch-sequential] Filters are useful in Interaction between components required.
executed, potentially concurrently. more than one application. Data structures Exchange of complex data structures between
Pipes route data streams between easily serializable. components required.
filters
Shared memory
Blackboard Independent programs, access and All calculation centers on a common, Programs deal with independent parts of the
communicate exclusively through a changing data structure; common data.
global repository known as Order of processing dynamically determined Interface to common data susceptible to
blackboard and data-driven. change. When interactions between the
independent programs require complex
regulation.
Rule-based Use facts or rules entered into the Problem data and queries expressible as Number of rules is large.
knowledge base to resolve a query simple rules over which inference may be Interaction between rules present.
performed. High-performance required.
Architectural Styles
Style Summary (3/4)
Interpreter
Interpreter Interpreter parses and executes the Highly dynamic behavior required. High High performance required.
input stream, updating the state degree of end-user customizability.
maintained by the interpreter
Mobile Code Code is mobile, that is, it is executed When it is more efficient to move processing Security of mobile code cannot be assured, or
in a remote host to a data set than the data set to processing. sandboxed.
When it is desirous to dynamically customize When tight control of versions of deployed
a local processing node through inclusion of software is required.
external code
Architectural Styles
Style Summary (4/4)
Implicit Invocation
Publish-subscribe Publishers broadcast messages to Components are very loosely coupled. When middleware to support high-volume data
subscribers Subscription data is small and efficiently is unavailable.
transported.
Event-based Independent components Components are concurrent and independent. Guarantees on real-time processing of events is
asynchronously emit and receive Components heterogeneous and network- required.
events communicated over event distributed.
buses
Peer-to-peer Peers hold state and behavior and Peers are distributed in a network, can be Trustworthiness of independent peers cannot
can act as both clients and servers heterogeneous, and mutually independent. be assured or managed.
Robust in face of independent failures. Resource discovery inefficient without
Highly scalable. designated nodes.
REST Mesh of components abstracting When extreme scalability in heterogeneous When scenarios are local and rather
state and functionality, uniquely application environments is required. specialized.
addressable over a constrained set When frequent changes are part of the non-
of well-defined operations. functional requirements.
Distributed Objects Objects instantiated on different Objective is to preserve illusion of location- When high overhead of supporting middleware
hosts transparency is excessive. When network properties are
unmaskable, in practical terms.
Agenda
Resources
• http://portal.acm.org/dl.cfm
• http://msdn.microsoft.com/en-us/architecture/default.aspx
• http://www.sei.cmu.edu/architecture/
• http://ieeexplore.ieee.org/Xplore/guesthome.jsp
• http://www.wwisa.org/
• http://www.iasahome.org/web/home/home