• No results found

Structural Patterns. Structural Patterns. Fritz Solms. October 16, 2015

N/A
N/A
Protected

Academic year: 2021

Share "Structural Patterns. Structural Patterns. Fritz Solms. October 16, 2015"

Copied!
44
0
0

Loading.... (view fulltext now)

Full text

(1)

Structural Patterns

Structural Patterns

Fritz Solms

(2)

Structural Patterns

What are structural patterns

What are structural patterns?

Choice of architectural patterns

one of the central architectural decisions. typically wide-ranging consequences.

Definition

A structural pattern is a template solution for a structure which has been shown to be able to address specific architectural concerns.

Structural patterns specify

Architectural components

optionally with responsibilities of each component. Connectivity constraints

(3)

Structural Patterns

Why use structural patterns?

Why Use Structural Patterns?

Each pattern is aligned with certain qualities.

easier to achieve certain quality attributes often at cost of others⇒trade-off

Specifying or identifying structural patterns

improves understanding

simplifies software architecture assessment and comparison, and facilitates communicating aspects of a software architecture.

(4)

Structural Patterns

Layering

The layering pattern

Components organized in layers.

Each layer has a high level responsibility.

Responsibility not prescribed by pattern. Specified during design.

Infrastructure constraint:

Components in one layer can only access components which are either

in same layer, or in next lower level layer

(5)

Structural Patterns

Layering

Examples

Examples of layering

Historically: widely for enterprise systems

n-tier

e.g. 2-tier, 3-tier, 5-tier

(6)

Structural Patterns

Layering

Examples

Client-Server (2-tier)

Client application provides access to humans (or systems)

presentation layer / access layer human adapter / system adapter

Server: commonly a database server

stores data

Business logic

(7)

Structural Patterns

Layering

Examples

(8)

Structural Patterns

Layering

Examples

(9)

Structural Patterns

Layering

Examples

Layered Organizations

1 Client access layer

dealer, web pages, call center, web services, . . .

2 Front-office layer

providing client-faced services

3 Back-office layer

providing back-office services

4 Infrastructure layer

(10)

Structural Patterns

Layering

Advantages and disadvantages of layering

Benefits of Layering

Pluggable and replaceable layers

e.g. replacing application client with web client replacing one backend system by another

Improved cohesion

through high-level responsibility localization

Complexity reduction

through reduced connectivity

Loose high-level coupling

through defined APIs for layers

Ability to mock out lower level layers

for testing and independent development

Layers can be developed by different teams

with different skills sets

Improved high-level component reuse

(11)

Structural Patterns

Layering

Advantages and disadvantages of layering

Concerns around Layering

Inflexible due to

rigid structure and communication constraints

Performance overheads caused by

communication and potentially encoding/decoding overheads across layers

High maintenance costs

with changes to lower layers impacting on higher layers.

Low innovation through

seeing just a small world

(12)

Structural Patterns

Microkernel

Microkernel

Core →Integration bus

message or request routing

Internal servers

backbone or base services,

robust, slowly evolving, reliable, . . .

External servers

Higher-level, client-facing services Flexible

Adapter

(13)

Structural Patterns

Microkernel

Uses of the microkernel pattern

Uses of microkernel

Example uses: SOA with ESB Operating systems

Internal servers for access to and management of system resources

SOEs

e.g. Corporate & Merchant banks.

solid, slowly evolving internal (back-office) services

transaction processing, regulatory reporting, procurement, . . . Flexible, rapidly evolving external (client facing) services

(14)

Structural Patterns

Microkernel

Benefits and challenges of the microkernel pattern

Benefits of the Microkernel Pattern

Infrastructure for flexible client faced services on robust slowly evolving core/internal services.

Simplified integration

each component only needs to know how to integrate with integration bus

Flexibility

through simple pluggability

ability to have different deployment configurations

Portability

by plugging in a different concrete lower-level services layer

Improved reuse

through simpler integration and adaptability across technologies, communication protocols and interfaces.

Improved maintainability due to

separation of low-level services from high-level services, and simplified integration

(15)

Structural Patterns

Microkernel

Benefits and challenges of the microkernel pattern

Concerns around the Microkernel Pattern

Performance

due to communication and routing overheads

Reliability

if integration bus is single point of failure

More complex process management

(16)

Structural Patterns

Blackboard

The Blackboard Pattern: Problem Analog

Have difficult mathematical problem.

Have asked each of a group of mathematicians None could solve problem.

Also do not have process for solution

e.g. ask mathematician 1 to solve sub-problem 1 followed by mathematician 2 solving sub-problem 2.

What now?

Get them together in front of blackboard.

See if they can auto-orchestrate a process solving the problem.

(17)

Structural Patterns

Blackboard

The Blackboard Pattern: Problem Analog

Have difficult mathematical problem.

Have asked each of a group of mathematicians None could solve problem.

Also do not have process for solution

e.g. ask mathematician 1 to solve sub-problem 1 followed by mathematician 2 solving sub-problem 2.

What now?

Get them together in front of blackboard.

See if they can auto-orchestrate a process solving the problem.

(18)

Structural Patterns

Blackboard

The Blackboard Pattern

Blackboard/knowledge repository

hosts problem specification & current state of solution.

The pool of expertsorprocessing unitswhich observes the blackboard

decide themselves when to contribute,

perform QA on contributions/modifications to blackboard

Controllerminimally involved.

Specify/feed problems. Manage vision.

(19)

Structural Patterns

Blackboard

Uses of the blackboard pattern

Uses of the Blackboard Pattern

Example uses: WHEREVER YOU NEED INNOVATION

Software development or knowledge capturing(open-source)

Blackboard: Version Control Repository, Wiki, . . .

Expert Pool: Open source community, society in general, . . . perform QA amongst themselves

Controller: Project lead specifying scope, general vision, . . .

Monitoring & Control systems,

Data (e.g. events) fed into blackboard

Monitoring units observe events & render them to user

Complex event processing units generate higher-level events from combination of lower level events ,

Control units react to events to perform some control actions e.g. industrial plants, cockpits, organizational monitoring and control, . . .

Space-based architectures

Commonly used for complex decision making

e.g. automated trading, airport traffic control, military systems which detect & track objects, . . .

JavaSpaces, GigaSpaces, Apache River, . . .

JAD sessions, research & marketing teams, . . . ,

(20)

Structural Patterns

Blackboard

Uses of the blackboard pattern

Uses of the Blackboard Pattern

Example uses: WHEREVER YOU NEED INNOVATION

Software development or knowledge capturing(open-source)

Blackboard: Version Control Repository, Wiki, . . .

Expert Pool: Open source community, society in general, . . . perform QA amongst themselves

Controller: Project lead specifying scope, general vision, . . .

Monitoring & Control systems,

Data (e.g. events) fed into blackboard

Monitoring units observe events & render them to user

Complex event processing units generate higher-level events from combination of lower level events ,

Control units react to events to perform some control actions e.g. industrial plants, cockpits, organizational monitoring and control, . . .

Space-based architectures

Commonly used for complex decision making

e.g. automated trading, airport traffic control, military systems which detect & track objects, . . .

JavaSpaces, GigaSpaces, Apache River, . . .

JAD sessions, research & marketing teams, . . . ,

(21)

Structural Patterns

Blackboard

Uses of the blackboard pattern

Uses of the Blackboard Pattern

Example uses: WHEREVER YOU NEED INNOVATION

Software development or knowledge capturing(open-source)

Blackboard: Version Control Repository, Wiki, . . .

Expert Pool: Open source community, society in general, . . . perform QA amongst themselves

Controller: Project lead specifying scope, general vision, . . .

Monitoring & Control systems,

Data (e.g. events) fed into blackboard

Monitoring units observe events & render them to user

Complex event processing units generate higher-level events from combination of lower level events ,

Control units react to events to perform some control actions e.g. industrial plants, cockpits, organizational monitoring and control, . . .

Space-based architectures

Commonly used for complex decision making

e.g. automated trading, airport traffic control, military systems which detect & track objects, . . .

JavaSpaces, GigaSpaces, Apache River, . . .

JAD sessions, research & marketing teams, . . . ,

(22)

Structural Patterns

Blackboard

Uses of the blackboard pattern

Uses of the Blackboard Pattern

Example uses: WHEREVER YOU NEED INNOVATION

Software development or knowledge capturing(open-source)

Blackboard: Version Control Repository, Wiki, . . .

Expert Pool: Open source community, society in general, . . . perform QA amongst themselves

Controller: Project lead specifying scope, general vision, . . .

Monitoring & Control systems,

Data (e.g. events) fed into blackboard

Monitoring units observe events & render them to user

Complex event processing units generate higher-level events from combination of lower level events ,

Control units react to events to perform some control actions e.g. industrial plants, cockpits, organizational monitoring and control, . . .

Space-based architectures

Commonly used for complex decision making

e.g. automated trading, airport traffic control, military systems which detect & track objects, . . .

JavaSpaces, GigaSpaces, Apache River, . . .

JAD sessions, research & marketing teams, . . . ,

(23)

Structural Patterns

Blackboard

Benefits and concerns around the blackboard pattern

Benefits of the Blackboard Pattern

Infrastructure for generatinginnovativesolution

Ability to solve difficult problems

Simplescalabilityacross grid of processors

subject to a scalable implementation of the blackboard.

Continuousqualityoptimization

every expert can see & react to contributions from any other expert.

Flexibility/maintainability

(24)

Structural Patterns

Blackboard

Benefits and concerns around the blackboard pattern

Concerns Around the Blackboard Pattern

Low cost Performance Accountability

(25)

Structural Patterns

Master-Slave

Master-Slave

Master distributes work across processing grid

may require data transportation or distributed/partitioned DB/FS

Often requires

aggregators/reducers

to calc statistical or inferred result from data bulk formonitorabilityandreliability

job and task tracking task restart on failure

(26)

Structural Patterns

Master-Slave

Uses of the master-slave pattern

Uses of the Master-Slave Pattern

Map-Reduce reference architecture and frameworks

e.g. Hadoop map reduce

Batch processing Data acquisition

Processing large data blocks

Search engines

Statistical analysis of financial stock data Vote counting, . . .

(27)

Structural Patterns

Master-Slave

Benefits and concerns

Benefits of Master-Slave

Scalability

Work is split up into independent sub-tasks executed by independent nodes on a slave grid.

Reliability/Fault Tolerant

Master oversees work done by slaves and requests work to be redone on slave failure

(28)

Structural Patterns

Master-Slave

Benefits and concerns

Concerns Around Master-Slave

May be difficult to divide labour and data Not suited for interactive processes

Security is difficult to guarantee in the context of distributed processing

particularly when processing data for different clients e.g. in a cloud environment

(29)

Structural Patterns

Hierarchical

The hierarchical pattern

Recursive containment hierarchy (similar to composite). Infrastructural constraint:

Communication only

between parent & child nodes using defined communication channels.

(30)

Structural Patterns

Hierarchical

Uses of the hierarchical pattern

Uses of Hierarchical (Composite) Pattern

Organizations

reporting and accountability hierarchies

Hierarchical master-slave systems

masters dish out work to slaves,

Inheritance hierarchies

enforcing commonalities (requirements & processes) can be used for base infrastructure for auditability, . . .

Hierarchical databases

widely used for naming & directory services inheritance of authorization parameters

Documents

a section may have sections.

Styling (e.g. CSS)

styling of parent node inherited by child node may be overridden by parent node

(31)

Structural Patterns

Hierarchical

Benefits and challenges of the hierarchical pattern

Benefits of Hierarchical Pattern

Performance&Scalability

Finding elements quickly Hierarchical master-slave

Reliability

oversight/accountability hierarchy

Responsibility localization

across levels of granularity

Improved maintainability

through inheritance

Auditability

(32)

Structural Patterns

Hierarchical

Benefits and challenges of the hierarchical pattern

Concerns around the use of Hierarchical

Reduced flexibility

due to rigid structure

Reduced ingenuity due to

exposure/access to only a small subset of world, other areas under control of another hierarchy

Increased cost

due to overheads of higher-level, non-processing layers.

In an organization it may result in a scenario where each employee is promoted to their personal level of incompetence.

(33)

Structural Patterns

Pipes and filters

The pipes & filters pattern

The pipes & filters pattern

Filters: Stateless services or pure functions

State does not survive across requests/calls. Functions: do not access environment Independent of other filters

Pipes : input and output pipes.

Potentially also error and logging pipes.

(34)

Structural Patterns

Pipes and filters

The pipes & filters pattern

Uses of pipes & filters

Unix command processing

ls|head−4|tail−2>fileContaining3rdAnd4thFileNames.txt

Functional programming

Media streaming/processing pipelines

decoding, object detection, image/sound manipulation, . . .

I/O streaming

objectIS=newObjectIS(newHashingIS(newBufferedIS(socket.getIS()))); SOA

orchestration of services across queues

Manufacturing sector

machines and conveyor belts

Workflow systems

can include filters comprising manual workflow steps

Media systems

1 signal source layer (media stream player, radio, CD player, . . . )

2 signal modification layer (pre-amplifier)

3 amplification layer (power amplifier)

(35)

Structural Patterns

Pipes and filters

The pipes & filters pattern

Benefits of the pipes and filters pattern

Flexibility andTime-To-Market

Can easily modify a workflow by adding/removing/replacing filters Can easily assemble new workflows from available functionality

Reuse andTestability

due to decoupling and even more so if pure functions.

Scalability andConcurrency

due to decoupling and even more so if pure functions.

Simpleauditability

(36)

Structural Patterns

Pipes and filters

The pipes & filters pattern

Concerns around the pipes and filters pattern

Performancecaused by communication overheads, en- and de-coding.

Difficult to achieveingenuity

Reliabilityas there is no high-level control or oversight Difficult to implementinteractive processes

(37)

Structural Patterns

Model-View-Controller (MVC)

Model-View-Controller (MVC)

Reduce presentation layers complexity & improve flexibility

by separating responsibilities:

1 Provide view onto information→View

2 React to user events→Controller

3 Provide business services & data→Model

letting them change independently (sort of)

Fully decouple

Model from both, View & Controller,

Model observed

by all Views

update themselves on model state changes potentially by Controller

(38)

Structural Patterns

Model-View-Controller (MVC)

(39)

Structural Patterns

Model-View-Controller (MVC)

(40)

Structural Patterns

Model-View-Controller (MVC)

Uses of the MVC pattern

Uses of the MVC Pattern

Most user interface libraries

Smalltalk, JavaFX, QT, Swing (sort-of) . . .

Web-based presentation layer frameworks

JSF, Django web framework, Spring web framework, Struts, ASP.Net . . .

(41)

Structural Patterns

Model-View-Controller (MVC)

Benefits and concerns around the MVC pattern

Benefits of the MVC Pattern

Simplification

through separation of concerns

Reuse

model components, view components

Maintainability

Different components can be developed & maintained by different teams

Model→Backend developers

View→UI designers

Controller→Front-end developers

Improved testability

Model/business services tested independent of UI UI tested with mock model.

(42)

Structural Patterns

Model-View-Controller (MVC)

Benefits and concerns around the MVC pattern

Concerns around the MVC Pattern

Maintainability

Model changes impact view & controller

Performance

More complex message patterns may result in performance issues Particularly if model and view/controller not co-located

Reuse

Coupling of view & controller to model may limit reuse Usually addressed with adapter or bridge

(43)

Structural Patterns

Patterns and quality attributes

Patterns and Quality Attributes

Quality Attributes Tactic P erf o rmance Scalabilit y Reliabilit y Securit y Auditabilit y Integrabilit y Flexibilit y Reusabilit y Maintainabilit y T estabilit y Affo rd abil it y Usabilit y Deplo y abilit y Layering O M M M M M M

Pipes & filters O M M N M M M M M

Microkernel H N N N N N M O O Blackboard H N M N N N N M O O Comp Graph O M Bridge O M N N N M M O O Hierarchical M M M M O H M O O MVC O M M N N M N M Master-Slave M N M O O O H H

(44)

Structural Patterns

Exercises

Exercises

1 For each structural pattern, try and find one or two examples in systems you have been working on. Discuss

a) how the pattern is manifested in that system,

b) why the pattern was used for that system,

c) the architectural trade-offs being made by using that pattern,

d) whether you agree with the use of the pattern or whether you would

References

Related documents