Structural Patterns Fritz Solms October 16, 2015
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 i.e. infrastructure of architectural components
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. Useful to understand vendor solutions (e.g. frameworks).
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
Layering Examples Examples of layering Historically: widely for enterprise systems n-tier e.g. 2-tier, 3-tier, 5-tier Also protocols, organizations,...
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 may be in client application or in database as stored procedures.
Layering Examples 3-tier Architecture
Layering Examples 5-tier Architecture
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 integration with suppliers, regulatory institutions,...
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 ability to reuse single layers or entire stack
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 other areas controlled by other hierarchies
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 to provide single access point
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
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
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 if not provided by architecture
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?
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. you could try and use the blackboard pattern
Blackboard The Blackboard Pattern Blackboard/knowledge repository hosts problem specification & current state of solution. The pool of experts or processing units which observes the blackboard decide themselves when to contribute, perform QA on contributions/modifications to blackboard Controller minimally involved. Specify/feed problems. Manage vision. Makes final decision if experts cannot agree.
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,...
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,...
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,...
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,..., Team brainstorms innovative solution.
Blackboard Benefits and concerns around the blackboard pattern Benefits of the Blackboard Pattern Infrastructure for generating innovative solution Ability to solve difficult problems Simple scalability across grid of processors subject to a scalable implementation of the blackboard. Continuous quality optimization every expert can see & react to contributions from any other expert. Flexibility/maintainability adding expert range of auto-orchestrated processes modified
Blackboard Benefits and concerns around the blackboard pattern Concerns Around the Blackboard Pattern Low cost Performance Accountability
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 for monitorability and reliability job and task tracking task restart on failure
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,...
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
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
Hierarchical The hierarchical pattern Recursive containment hierarchy (similar to composite). Infrastructural constraint: Communication only between parent & child nodes using defined communication channels. Also inheritance hierarchies.
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
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 inherit base auditability infrastructure from base entity
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.
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. Assemble higher-level stateless services from lower level ones.
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 = new ObjectIS(new HashingIS(new BufferedIS(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)
Pipes and filters The pipes & filters pattern Benefits of the pipes and filters pattern Flexibility and Time-To-Market Can easily modify a workflow by adding/removing/replacing filters Can easily assemble new workflows from available functionality Reuse and Testability due to decoupling and even more so if pure functions. Scalability and Concurrency due to decoupling and even more so if pure functions. Simple auditability through logging all filter inputs and outputs (off queues)
Pipes and filters The pipes & filters pattern Concerns around the pipes and filters pattern Performance caused by communication overheads, en- and de-coding. Difficult to achieve ingenuity Reliability as there is no high-level control or oversight Difficult to implement interactive processes
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 Components may be hosted on different nodes.
Model-View-Controller (MVC) Structure of MVC
Model-View-Controller (MVC) Dynamics of MVC
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...
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.
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
Patterns and quality attributes Patterns and Quality Attributes Tactic Performance Scalability Reliability Security Quality Attributes Auditability Layering Pipes & filters Microkernel Blackboard Comp Graph Bridge Hierarchical MVC Master-Slave Integrability Flexibility Reusability Maintainability Testability Affordability Usability Deployability
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 suggest an alternative pattern instead.