Application Architectures, Design Patterns

Similar documents
1 Software Architecture

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

The Strategy Pattern Design Principle: Design Principle: Design Principle:

SDC Design patterns GoF

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Using Design Patterns in Java Application Development

Object-Oriented Design

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Design Patterns. An introduction

DESIGN PATTERN - INTERVIEW QUESTIONS

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

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

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

Applying the Observer Design Pattern

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Design patterns. Jef De Smedt Beta VZW

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

Introduction to Software Engineering: Object Design I Reuse & Patterns

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Object-Oriented Oriented Programming

Software Design COSC 4353/6353 D R. R A J S I N G H

Information systems modelling UML and service description languages

Applying the Decorator Design Pattern

Design Patterns. SE3A04 Tutorial. Jason Jaskolka

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Object Oriented Paradigm

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Object-oriented Software Design Patterns

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Software Engineering I (02161)

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

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

What is Design Patterns?

Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring.

Applying the Factory Method Design Pattern

Patterns. Erich Gamma Richard Helm Ralph Johnson John Vlissides

An Introduction to Patterns

Object-Oriented Design

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Design Patterns: Structural and Behavioural

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

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool

Applying Design Patterns to SCA Implementations

Enterprise Java Development using JPA, Hibernate and Spring. Srini Penchikala Detroit JUG Developer Day Conference November 14, 2009

Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1

CS/CE 2336 Computer Science II

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

administrivia today UML start design patterns Tuesday, September 28, 2010

Software Development Project. Kazi Masudul Alam

Review Software Engineering October, 7, Adrian Iftene

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

Tuesday, October 4. Announcements

Software Engineering I (02161)

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

Design Patterns. "Gang of Four"* Design Patterns. "Gang of Four" Design Patterns. Design Pattern. CS 247: Software Engineering Principles

Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3

Software Architecture With ColdFusion: Design Patterns and Beyond Topics Outline Prepared by Simon Horwith for CFUnderground 6

CS 247: Software Engineering Principles. Design Patterns

Patterns Architectural Styles Archetypes

Design Patterns. (and anti-patterns)

Software Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology

CS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995

MVC. Model-View-Controller. Design Patterns. Certain programs reuse the same basic structure or set of ideas

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

The Design Patterns Matrix From Analysis to Implementation

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

3 Product Management Anti-Patterns by Thomas Schranz

An Introduction to Patterns

UNIT I Introduction to Design Patterns

Brief Note on Design Pattern

CPSC 310 Software Engineering. Lecture 11. Design Patterns

CS251 Software Engineering Lectures 18: Intro to DP

Topics in Object-Oriented Design Patterns

2.1 Design Patterns and Architecture (continued)

Lecture 4: Observer Pattern, Event Library and Componentization

2.1 Design Patterns and Architecture (continued)

Design patterns. OOD Lecture 6

Design Patterns. CSC207 Fall 2017

Design Patterns Reid Holmes

Summary of the course lectures

What is Design Patterns?

UNIT I Introduction to Design Patterns

Extensibility Design Patterns From The Initial Stage of Application Life-Cycle

DESIGN PATTERNS MOCK TEST DESIGN PATTERNS MOCK TEST II

Design Patterns. CSC207 Winter 2017

A Case Study of Gang of Four (GoF) Patterns: Part 3

APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS

A Rapid Overview of UML

I, J. Key-value observing (KVO), Label component, 32 text property, 39

CAS 703 Software Design

Agile Architecture. The Why, the What and the How

THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS

SOFTWARE ENGINEERING SOFTWARE DESIGN. Saulius Ragaišis.

Overview of Patterns: Introduction

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

Transcription:

Application Architectures, Design Patterns Martin Ledvinka martin.ledvinka@fel.cvut.cz Winter Term 2017 Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 1 / 42

Contents 1 Software Architecture 2 Architectural Styles Layered Architecture 3 Design Patterns GoF Design Patterns Enterprise Design Patterns Other Useful Patterns 4 Spring Web Application Architecture 5 Conclusions Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 2 / 42

Some buzzwords and acronyms for today Software architecture Design pattern Separation of concerns Single responsibility principle Keep it simple, stupid (KISS) Don t repeat yourself (DRY) Don t talk to strangers (Demeter s law) Inversion of Control (IoC) Dependency injection (DI) Data Access Object (DAO) Model View Controller (MVC) Hollywood principle Encapsulation High cohesion, loose coupling artin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 3 / 42

Software Architecture Software Architecture Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 4 / 42

Software Architecture What is a software architecture? The software architecture of a program or computing system is the structure or structures of the system, which comprise software elements, the externally visible properties of those elements, and the relationships among them. Architecture is concerned with the public side of interfaces; private details of elements details having to do solely with internal implementation are not architectural. Bass, Clements, and Kazman Software Architecture in Practice (2nd edition) Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 5 / 42

Software Architecture Software architecture Architecture describes the overall structure of a software system. Good architecture enables smooth evolution of the system. It must take into account things like Deployment environment, Platform and technology specifics, Expected system scope. Architecture Changes slowly Influences the whole system Architectural styles Component design Rapid change through refactoring Specific for the component Design patterns Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 6 / 42

Software Architecture Architecture design principles Standard design principles also apply to system-wide architecture, i.e. Separation of concerns, Single responsibility principle, Law of Demeter, Don t repeat yourself. Before you design the system architecture, you need to Determine application type, Determine deployment strategy and environment, Determine technologies to use, Determine quality attributes, Determine crosscutting concerns. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 7 / 42

Software Architecture Architecture example Figure : System architecture example. Source: https://msdn.microsoft.com/en-us/library/ee658124.aspx Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 8 / 42

Software Architecture System architecture Usually consists of multiple architectural styles, Should be well understood by the team, Should be documented (diagrams, pictures, notes), Should clearly expose system structure, while hiding implementation details, E.g. show where stuff happens, but not how, Address all user scenarios (eventually), Should handle both functional and non-functional requirements, Evolves as the software grows. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 9 / 42

Architectural Styles Architectural Styles Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 10 / 42

Architectural Styles Architectural styles There exist plenty of architectural styles, They are usually combined in an application, Different styles are suitable for different scenarios, Various ways of architectural style classification. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 11 / 42

Architectural Styles Architectural styles - Communication Service-Oriented Architecture Distributed applications provide services for each other, Using standard protocols and data formats (REST HTTP and JSON/XML), Loose coupling, easy implementation switch, Microservices. Figure : SOA system example. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 12 / 42

Architectural Styles Architectural styles - Communication II Message Bus Central message queue handles message distribution, Asynchronous messages between clients, Loose coupling, scalability, Enterprise Service Bus provided by Oracle, IBM etc. Figure : ESB architecture. Source: https://docs.oracle.com/cd/ E23943_01/doc.1111/e15020/img/esb_architecture.gif Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 13 / 42

Architectural Styles Architectural styles - Deployment Client/Server Client sends requests, server responds, Web applications use this pattern, Server possible single point of failure and scalability issue. N(3)-tier Independent tiers providing functionality, Easier scaling, E.g. load balancing, company firewall. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 14 / 42

Architectural Styles Architectural styles - Domain Domain-driven Design Business components represent domain entities, Suitable for modelling complex domains, Common language and model for developers and domain experts. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 15 / 42

Architectural Styles Architectural styles - Structure Object-oriented Objects consist of both behaviour and data, Natural representation of real world, Encapsulation of the implementation details. Layered More on layers later... Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 16 / 42

Architectural Styles Architectural styles - Structure II Component-based System decomposed into logical or functional components, Components provide public interfaces, Supports separation of concerns and encapsulation, Components can be managed by architecture provider, Dependency injection and Service locator used to managed dependencies, Components can be distributed, Higher level than OOP. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 17 / 42

Architectural Styles Layered Architecture Layered architecture Layers of related functionality, Typical for web applications, Behaviour encapsulation, clear separation of concerns, high cohesion, loose coupling, Testability. Figure : Layered system architecture. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 18 / 42

Architectural Styles Layered Architecture Layered architecture II In contrast to N-tier architecture, the layers are usually in one process (e.g. application server), Each component communicates only with other components within the same layer or in the layer(s) below it, Strict interaction Layer communicates only with the layer directly below, Loose interaction Layer can communicate also with layers deeper below, Crosscutting concerns stem across all layers (e.g. security, logging). Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 19 / 42

Design Patterns Design Patterns Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 20 / 42

Design Patterns Design patterns Design patterns represent generally applicable solutions to commonly occurring problems. Patterns mostly consist of (this was cemented by the GoF): Pattern name Simple identification useful in communication, Problem Description of the problem and its context, Solution Solution of the problem (good practice), Consequences Possible trade-offs of applying the pattern. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 21 / 42

Design Patterns GoF Design Patterns Gang of Four Patterns Based on the book Design Patterns: Elements of Reusable Object-Oriented Software. Bible of design patterns, Patterns applicable to all kinds of object-oriented software. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 22 / 42

Design Patterns GoF Design Patterns Creational Patterns Abstract Factory Interface for creating families of related objects, Builder Instance construction process in a separate object, Factory Method Subclasses decide which class to instantiate, Prototype Build instances based on a prototype, Singleton Only one instance of the class. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 23 / 42

Design Patterns GoF Design Patterns Structural Patterns Adapter Convert interface of one class to a different interface using an adapter (e.g. for legacy classes), Bridge Decouple abstraction from implementation, Composite Build tree-like structure of objects, Decorator Add or alter behaviour of another object by wrapping it in a class with the same interface (e.g. Java I/O streams), Facade Provide a unified interface to a set of interfaces, Flyweight Use sharing to support a large number of fine-grained objects, Proxy Provide a placeholder for another object to control access to it (e.g. Spring bean proxies). Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 24 / 42

Design Patterns GoF Design Patterns Decorator Decorator in Java I/O BufferedReader in = new BufferedReader(new FileReader(new File("input.txt"))); Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 25 / 42

Design Patterns GoF Design Patterns Behavioral Patterns Chain of Responsibility Multiple objects in a chain can handle a request (e.g. request filters), Command Encapsulate a request in an object (e.g. undo functionality), Interpreter Interpreter for a language and its grammar, Iterator Provide a way to access elements of an aggregate object (e.g. Java collections), Iterator<String> it = set.iterator(); Mediator An object that encapsulates how a set of objects interact, Memento Capture object s state so that it can be restored to this state later, Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 26 / 42

Design Patterns GoF Design Patterns Behavioral Patterns II Observer Decoupled notification of changes of object s state, State Allows object s behaviour to change based on its internal state, Strategy A family of algorithms, which can be interchanged independently of the client, Template method Define a skeleton of an algorithm and let subclasses fill in the details, Visitor Represent an operation to be performed on the elements of an object structure. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 27 / 42

Design Patterns Enterprise Design Patterns Enterprise Design Patterns Mostly based on the book Patterns of Enterprise Application Architecture. Design patterns used especially in enterprise software, Similarly to GoF design patterns, they originate from best practice solutions to common problems, but this time in enterprise application development. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 28 / 42

Design Patterns Enterprise Design Patterns PEAA Data Transfer Object (DTO) Object that carries data between processes in order to reduce the number of calls, Useful e.g. when JPA entities are not the best way of carrying data between REST interfaces. Lazy Load Object does not contain all of its data initially, but knows how to load it, Useful for objects holding large amounts of data (e.g. binary data), Often overused as a way of premature optimization. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 29 / 42

Design Patterns Enterprise Design Patterns PEAA II Model View Controller (MVC) Splits user interface interaction into three distinct roles, Decouples UI rendering from data and UI logic, UI implementation interchangeable. Unit Of Work Maintains objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems, Common in JPA implementations (e.g. Eclipselink). Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 30 / 42

Design Patterns Other Useful Patterns Data Access Object (DAO) Data access object encapsulates all access to the data source, Abstract interface hides all the details of data source access (data source can be a RDBMS, an external service, a linked data repository). Figure : Common Data access object hierarchy. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 31 / 42

Design Patterns Other Useful Patterns Inversion of Control (IoC) Most common when working with frameworks, The framework takes control of what and when gets instantiated and called, The framework embodies some abstract design and we provide behaviour in various places, Especially important in applications which react to some client s actions, Be it a different application, or a client using your application s UI, aka The Hollywood Principle Don t call us. We ll call you. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 32 / 42

Design Patterns Other Useful Patterns IoC II Figure : Inversion of Control in a Spring application. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 33 / 42

Design Patterns Other Useful Patterns Dependency Injection An assembler takes care of populating a field in a class with an appropriate implementation for the target interface, Enables the application to use loosely coupled components with interchangeable implementations. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 34 / 42

Design Patterns Other Useful Patterns Dependency Injection II Figure : Dependency injection principle. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 35 / 42

Spring Web Application Architecture Spring Web Application Architecture Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 36 / 42

Spring Web Application Architecture Spring web application architecture Typically layered, Usually three layers, Relies on DI and IoC provided by the Spring container, Various possibilites for the top and bottom layers: Spring MVC, REST services, SOAP services for the web layer, Spring JPA, Spring JDBC, Integrated support for security. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 37 / 42

Spring Web Application Architecture Spring application layers Figure : Spring web application architecture. Source: https://www.petrikainulainen.net/wp-content/uploads/ spring-web-application-layers.png Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 38 / 42

Conclusions Conclusions Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 39 / 42

Conclusions Conclusions Application design does matter, Architecture consists of multiple architectural styles, Design patterns are more fine grained than architectural styles, Web applications usually follow the layered style. Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 40 / 42

Conclusions The End Thank You Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 41 / 42

Conclusions Resources M. Fowler: Patterns of Enterprise Application Architecture, E. Gamma, R. Johnson, R. Helm, J. Vlissides: Design Patterns: Elements of Reusable Object-Oriented Software, E. Evans: Domain Driven Design: Tackling Complexity in the Heart of Software, Lectures of Tomáš Černý A7B36ASS https://msdn.microsoft.com/en-us/library/ee658098.aspx https: //www.petrikainulainen.net/software-development/design/ understanding-spring-web-application-architecture-the-classic Martin Ledvinka (martin.ledvinka@fel.cvut.cz) Application Architectures, Design Patterns Winter Term 2017 42 / 42