Avancier Methods. Very basic design patterns. It is illegal to copy, share or show this document

Similar documents
GRASP Design Patterns A.A. 2018/2019

Object-Oriented Design II - GRASP

Eliminate enterprise software design instability - protect variations! Nickolay Kofanov

Responsibilities. Using several specific design principles to guide OO design decisions.

Object-Oriented Design I

17. GRASP: Designing Objects with Responsibilities

ADVANCED SOFTWARE DESIGN LECTURE 7 GRASP

Object-Oriented Design

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides.

Avancier Methods (AM) Software Architecture Modularity and OO presumptions

Architectural Styles II

CS 575: Software Design

Introduction to Object Oriented Analysis and Design

Application Architectures, Design Patterns

Architectural Styles I

Object Analysis & Design in the textbook. Introduction to GRASP: Assigning Responsibilities to Objects. Responsibility-Driven Design

Object-Oriented Design

Object-Oriented Design I - SOLID

1 Software Architecture

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Appendix A - Glossary(of OO software term s)

ADVANCED SOFTWARE DESIGN LECTURE 4 SOFTWARE ARCHITECTURE

Model-View-Control Pattern for User Interactive Systems

GRASP 2. CSC 440: Software Engineering Slide #1

GRASP ing at the First 5 Patterns Principles CSSE 574: Session 3, Part 4

Principles of Software Construction: Objects, Design, and Concurrency. Assigning Responsibilities to Objects. toad. Jonathan Aldrich Charlie Garrod

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

XVIII. Software Architectures

Element: Relations: Topology: no constraints.

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

Model-view-controller. An architecture for UI

Software Design and Analysis CSCI 2040

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Software Design and Analysis CSCI 2040

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Avancier Methods (AM) TECHNIQUES. Client-Server Systems

Web Presentation Patterns (controller) SWEN-343 From Fowler, Patterns of Enterprise Application Architecture

COMP 6471 Software Design Methodologies

CS 307: Software Engineering. Lecture 10: Software Design and Architecture

5/9/2014. Recall the design process. Lecture 1. Establishing the overall structureof a software system. Topics covered

Chapter 1: Distributed Information Systems

Design Engineering. Overview

A2A EAI. Overview and recommendations Data Transport. Jerome CAPIROSSI. people are keen to argue since they find themselves to be affected.

Test Driven Development (TDD)

Architectural patterns and models for implementing CSPA

Distributed Systems Architectures. Ian Sommerville 2006 Software Engineering, 8th edition. Chapter 12 Slide 1

Work groups meeting 3

CS342: Software Design. November 21, 2017

Last Time: Object Design. Comp435 Object-Oriented Design. Last Time: Responsibilities. Last Time: Creator. Last Time: The 9 GRASP Patterns

CAS 703 Software Design

XVIII. Software Architectures

Chapter 13: Architecture Patterns

A few more things about Agile and SE. Could help in interviews, but don t try to bluff your way through

Assigning Responsibilities by Larman

Services Oriented Architecture and the Enterprise Services Bus

Avancier Methods (AM) Software Architecture Diagrams

CS342: Software Design. Oct 9, 2017

Architectural Styles I

Design patterns. Jef De Smedt Beta VZW

An Introduction to Software Architecture By David Garlan & Mary Shaw 94

Design. Eric McCreath

XIX. Software Architectures

J2EE AntiPatterns. Bill Dudney. Object Systems Group Copyright 2003, Object Systems Group

Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions

Four More GRASP Principles CSSE 574: Session 5, Part 2

Azure Integration Services

Gustavo Alonso, ETH Zürich. Web services: Concepts, Architectures and Applications - Chapter 1 2

Slides copyright 1996, 2001, 2005, 2009, 2014 by Roger S. Pressman. For non-profit educational use only

How EDA extends SOA and why it is important

DRS: Advanced Concepts, Best Practices and Future Directions

An Introduction to Software Architecture By David Garlan & Mary Shaw 94

Architectural Code Analysis. Using it in building Microservices NYC Cloud Expo 2017 (June 6-8)

Basic Properties of Styles

N-Tiered Enterprise Styles. Example 1. Key Concepts. Component-Based Software Engineering. ECE493-Topic 4 Winter 2006

02291: System Integration

CAS 703 Software Design

Goal: Offer practical information to help the architecture evaluation of an SOA system. Evaluating a Service-Oriented Architecture

6/20/2018 CS5386 SOFTWARE DESIGN & ARCHITECTURE LECTURE 5: ARCHITECTURAL VIEWS C&C STYLES. Outline for Today. Architecture views C&C Views

Client Code - the code that uses the classes under discussion. Coupling - code in one module depends on code in another module

In this Lecture you will Learn: System Design. System Architecture. System Architecture

Service-Oriented Architecture

Information Expert (or Expert)

DISCUSSION 5min 2/24/2009. DTD to relational schema. Inlining. Basic inlining

Patterns Architectural Styles Archetypes

Distribution and Integration Technologies

Architectural Design

Chapter 2 Web Development Overview

Credit where Credit is Due. Goals for this Lecture. Introduction to Design

Microservices Beyond the Hype. SATURN San Diego May 3, 2016 Paulo Merson

Expanding Our Horizons. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 9 09/25/2011

Outline. Operating System Security CS 239 Computer Security February 23, Introduction. Server Machines Vs. General Purpose Machines

Clean Architecture Patterns, Practices, and #sddconf

Serverless and APIs: Rethinking Curriculum in Higher Education. Munir Mandviwalla and Jeremy Shafer Temple University

Software System/Design & Architecture. Eng.Muhammad Fahad Khan Assistant Professor Department of Software Engineering

Managing Data at Scale: Microservices and Events. Randy linkedin.com/in/randyshoup

An Introduction to Patterns

Heresies and Dogmas in Software

Introduction to Software Engineering 10. Software Architecture

Architectural Design. CSCE Lecture 12-09/27/2016

Clean Architecture Patterns, Practices, and #DevSum17

Transcription:

Methods Very basic design patterns It is illegal to copy, share or show this document (or other document published at http://avancier.co.uk) without the written permission of the copyright holder Copyright Limited 2007-2016

Design patterns There are patterns for enterprise architecture solution architecture software architecture A design pattern is a general shape that recurs in many cases It should be a general solution to a general design problem be a tried and tested design speed up development encourage consistency, help standardise how design is done in an enterprise. reduce the risk of reliance on an individual designer. Copyright Limited 2007-2016

Patterns as diagrams Some patterns are available in the form of code. But patterns are usually represented in diagrams If you think you have a pattern, you must be able to draw a diagram of it. This is a crude, but vital rule. If you can't draw it, it isn't a pattern. A pattern defines a field of spatial relations, and it must always be possible to draw a diagram for every pattern. Christopher Alexander (1979) in The Timeless Way of Building Copyright Limited 2007-2016

Encapsulation Many design patterns are based an assumption Each component in it is encapsulated and defined by its input/output interface the discrete events it can process and services it can offer. On its own, encapsulation isn t a pattern But it is usually assumed in other patterns. Copyright Limited 2007-2016

A simple and common pattern: Façade Problem: How can a client avoid being too tightly coupled with a server subsystem? How to aggregate services into a coarser-grained component? Client 1 Client 2 Client 3 A E Server system B C D Solution: Introduce a façade that provides a unified interface for different clients, and makes the subsystem easier to use So clients know what the subsystem does for them, but nothing else Client 1 Client 2 Client 3 Fac A E B D C Copyright Limited 2007-2016

Fowler example of a Facade The façade simplifies a remote invocation for an address Copyright Limited 2007-2016

Alternative patterns Capable architects understand the available patterns look to use them in the right circumstances choose between alternative patterns by trading off their pros and cons Copyright Limited 2007-2016

Alternative patterns: Centralisation and Distribution A never-ending debate How far should powers be distributed to many nodes/places? centralised in one node/place? a Europe of Regions? Copyright Limited 2007-2016

Alternative patterns to be discussed Centralising F E Hub and Spoke CRM Hub DW ERP Billing Hierarchical layering Client layer Server layer Client Server Client Server CRM Fork/Orchestration Controller ERP Billing One schedules and directs the others: centralises intelligence about a process Distributing Point to Point CRM System Peer to Peer Chain/Choreography F ERP Component Component CRM ERP Billing E DW Billing System Component Component All interact and cooperate: distributes intelligence about a process Copyright Limited 2007-2016

Point to Point v Hub and Spoke F E Point to Point CRM ERP Billing DW Subsystems talk to each other directly. Can be faster and simpler OK where inter-component communication is 1 to 1 components at either endpoint are stable. F E Hub and Spoke CRM ERP Hub Billing DW Subsystems communicate via some kind of mediator or middleware. Can be more complex and slower than point-topoint integration. Better where inter-component communication is many to many components at either endpoint are volatile. Copyright Limited 2007-2016

Hierarchical layer v Peer to Peer Hierarchical layering Oft used to structure a complicated system. Client layer Client Client Machine architecture (programming language, OS, device drivers and CPU instruction sets, logic gates inside chips) Network architecture (FTP, TCP, IP, Ethernet). Server layer Server Server Software architecture (UI, Logic, Database) Subsystem Subsystem Peer to Peer Component Component Component Component Sometimes said to be a bad thing fragile and unstable structure difficult to understand and maintain undermine testability, parallel development, and reuse. Copyright Limited 2007-2016

Peer-to-peer structures Given a system structure with co-dependent components Cyclical dependency arrows Order Product Suppose you restructure it to eliminate all cyclic dependencies? The result will be a hierarchically-layered structure Copyright Limited 2007-2016

Hierarchically layered structure Higher-level components depend on lower-level ones, but not vice-versa The structure often resembles what Barry Boehm called a Mosque Shape. Order Product Copyright Limited 2007-2016

Hierarchical layering in enterprise applications Variations of a three-layer software architecture are common UI/Presentation Layer Business Domain Layer Data source Layer Copyright Limited 2007-2016

Software Layers <> Platform Tiers Layers and Tiers influence each other But don t perfectly correspond UI/Presentation Layer e.g. HTTP requests. Display of windows or HTML pages Client Device Tier Network Business Domain Layer The business logic that is the function of the system. Triggered by commands and queries. Data source layer Communication with databases, transaction managers, messaging systems etc. Web/App Server Tier Network Data Server Tier Copyright Limited 2007-2016

Where are business domain rules executed? A mantra of early OO design was that all business rules belong (in domain objects) in the app server tier In practice Validation of input data items against data types -> Client Device Tier Network Workflow logic and some business rules -> Web/App Server Tier Network Data integrity and other data-bound rules -> Data Server Tier Copyright Limited 2007-2016

Fork/Orchestration v Chain/Choreography CRM Fork/Orchestration Controller ERP Billing One schedules and directs others: centralises intelligence about a process Fork/Orchestration: centralises intelligence about a process sequence in a workflow controller that supervises and orchestrates the procedure. A controller directs other components to complete the process. It manages the sequence of activities by invoking components in turn. CRM Chain/Choreography ERP Billing All interact and cooperate: distributes intelligence about a process Chain/Choreography: distributes intelligence about a process sequence between several entity or domain components. Components cooperate to complete the process. Each component does part of the work, then calls the next component (cf. pipe and filter.) Copyright Limited 2007-2016

Fork/Orchestration v Chain/Choreography Chain: Domain Objects cooperate to perform a transaction Command :Pupil :School (new) :School (old) pupiltransfer (PupilNum, NewSchoolNum): Error removepupil (OldSchoolNum) addpupil (NewSchoolNum): NoRoomError Fork: A controller orchestrates the Domain Objects Command :PupilTransfer :Pupil :School (new) :School (old) pupiltransfer (PupilNum, NewSchoolNum): Error pupiltransfer (PupilNum): OldSchoolNum Transaction or Session Controller removepupil (OldSchoolNum) addpupil (NewSchoolNum): NoRoomError Copyright Limited 2007-2016

Alternative patterns Capable architects understand the available patterns look to use them in the right circumstances choose between alternative patterns by trading off their pros and cons. You should understand the problem you have; the problem the pattern is intended to solve; the benefits, costs and alternatives; the trade-offs between alternative patterns whether the pattern is or should be a local standard. Copyright Limited 2007-2016

What can we learn from Software Design Patterns? All system design is about designing required processes dividing the system into actors/components. organising the actors/components to perform processes At least some Software Design Patterns are relevant to enterprise application integration the design of human activity systems Copyright Limited 2007-2016

Beware Patterns are a starting point Every pattern is incomplete You have the responsibility of completing it in the context of your own system Martin Fowler Copyright Limited 2007-2016

Footnotes Classic patterns in enterprise application architecture GRASP pattern Demeter s law Copyright Limited 2007-2016

Classic patterns in enterprise application architecture Transaction script Centralises intelligence about the process for an event or enquiry A simple procedural model needs only a simple data source layer Start with opening a transaction and end with closing it Object-oriented Distributes intelligence about a process between entities Table module One object for each database table (record set) Domain model One object for each entity instance Simple domain model: mostly 1 OO class to 1 database table Rich domain model: complex class to table mapping anecdotal observations put the effort of mapping to a relational database at around a third of programming effort a cost that continues during maintenance. Fowler Copyright Limited 2007-2016

Choosing between patterns Fowler drew this graph Limiting the use of rich domain models to highly complex situations OO book authors like to write about those situations

Transaction script However much of an object bigot you become, don t rule out Transaction Script. There are a lot of simple problems, and a simple solution will get you up and running much faster. Many scripts act directly on the database, putting SQL into the procedure. The simplest Transaction Scripts contain their own database logic Transaction Script Command :PupilTransfer This is still model of a kind! The procedure may share subroutines pupiltransfer (PupilNum, NewSchoolNum): Error Replace Pupil Foreign Key Update Old School Update New School School-Pupil Database Copyright Limited 2007-2016

By the way Fowler drew these diagrams to illustrate how each pattern works for calculating revenue recoginations in a case study

The GRASP pattern A good designer can mix alternative patterns Use each pattern where it is appropriate. The GRASP pattern can be used to design a structure than compromises between Fork/Orchestration Chain/Choreography styles. Copyright Limited 2007-2016

The General Responsibility Assignment Software Pattern Craig Larman uses it to advance various principles for designing the interactions between components, including these five GRASP Expert Meaning Assign a responsibility to the expert component, which has the data to fulfil the responsibility Creator Low-Coupling High-Cohesion Controller Assign a responsibility for creating an object (or entity instance) to the component that collects or holds the object s initial data Ensure coupling between components remains low. Ensure cohesion within a component remains high. Create components to handle events in the end-to-end process Copyright Limited 2007-2016

Application of the GRASP design pattern The system remembers the names of Schools the Pupils currently registered in each School the PupilTotal for each School. If the new School s maximum number of pupils if not exceeded, and the Pupil Transfer event completes, then a Pupil will be moved from his/her current School to his/her new School, Command :PupilTransfer :Pupil :School (new) :School (old) pupiltransfer (PupilNum, NewSchoolNum): Error pupiltransfer (PupilNum), NewSchoolNum : removepupil (OldSchoolNum) addpupil (NewSchoolNum): NoRoomError Copyright Limited 2007-2016

Demeter s Law (1) A component should know only a few (<6?) other closely-related components. (2) A component should talk only to its immediate relatives; not reach through them to talk to components the relatives know. Paradox To enforce (1), the designer may have to add intermediate components (containers, controllers or brokers or facades). This tends to contravene (2) Copyright Limited 2007-2016

Input-driven v Model-driven Inputs feed state change events to the data servers Command PupilTransfer Pupil School (new) School (old) pupiltransfer (PupilNum, NewSchoolNum): Error pupiltransfer (PupilNum, NewSchoolNum) removepupil (OldSchoolNum) addpupil (NewSchoolNum): NoRoomError A data server publishes state change events to UI views View Event Trade Unit Price Stock/Share Show Report Copyright Limited 2007-2016