Top Banner
Programação de Sistemas Distribuidos Paulo Gandra de Sousa [email protected] Mestrado em Engenharia Informática DEI/ISEP
33

Patterns fro distributed systems

Nov 18, 2014

Download

Technology

Paulo Sousa

 
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Patterns fro distributed systems

Programação de

Sistemas

Distribuidos

Paulo Gandra de Sousa

[email protected]

Mestrado em Engenharia Informática

DEI/ISEP

Page 2: Patterns fro distributed systems

Disclaimer

Parts of this presentation are from:

Paulo Sousa (PARS)

Ron Jacobs (ARC01)

1

ISEP/IPP

Page 3: Patterns fro distributed systems

Today’s lesson

Design Patterns

Patterns for distributed Systems

Service Orientation

2

ISEP/IPP

Page 4: Patterns fro distributed systems

DESIGN PATTERNS

3

ISEP/IPP

Page 5: Patterns fro distributed systems

4

ISEP/IPP

What is a Pattern?

Each pattern describes a problem that occurs over and over again in our

environment and then describes the core of the solution to that problem in such a

way that you can use this solution a million times over without ever doing it

the same way twice.

Christopher Alexander

Page 6: Patterns fro distributed systems

5

ISEP/IPP

What is a design Pattern?

A design pattern names, abstracts, and identifies the key aspects of a common design structure that make it useful for creating a reusable object-oriented

design.

Design Patterns-Elements of Reusable Object-oriented Software, Gamma et al.

(Gang of Four)

Page 7: Patterns fro distributed systems

6

ISEP/IPP

What a pattern is not

A miracleous receipt

source: British Medical Journal

Page 8: Patterns fro distributed systems

7

ISEP/IPP

What is a pattern

A set of best-practices

A typified solution for a common problem in a

giving context

Creates a common vocabulary

Patterns are discovered not invented

“Patterns are half-baked”

Martin Fowler

Page 9: Patterns fro distributed systems

Anti-pattern

Na example of what not to do

Proven techniques that have shown bad

results

8

ISEP/IPP

Page 10: Patterns fro distributed systems

PATTERNS FOR

DISTRIBUTED

APPLICATIONS14

ISEP/IPP

Page 11: Patterns fro distributed systems

15

ISEP/IPP

Architecture

“client” application

Service

Gateway

“server” application

Remote

Façade

Service

Layer

Business

logic

Data

Transfer

Objectcontract

Page 12: Patterns fro distributed systems

16

ISEP/IPP

Service Gateway

An object that encapsulate the code that implements the

consumer portion of a contract. They act as proxies to

other services, encapsulating the details of connecting to

the source and performing any necessary translation.

fonte: Enterprise Solution Patterns Using .NET

Pattern

Page 13: Patterns fro distributed systems

17

ISEP/IPP

Service Gateway

Hides the details of accessing the service (ex., network protocol)

May be considered a data access component

Native support from most tools (e.g., Visual Studio, Netbeans, Rational software Architect) by web service proxies

See also Proxy and Broker pattern

Pattern

Page 14: Patterns fro distributed systems

18

ISEP/IPP

Remote Façade

Provides a coarse-grained façade on

fine-grained objects to improve efficiency

over a network

fonte: Patterns of Enterprise Application Architecture

Pattern

Page 15: Patterns fro distributed systems

19

ISEP/IPP

Remote Facade

Domain object interfaces are tipically fine grained

Inadequeate for remote operations

Create a surronding layer above domain objects

Local clients use the local interface

The facade may encapsulate the interface of one or more business objects Domain objects:

Address.New

Address.Set

Person.AddAddress

Person.Update

Remote Facade: AddressFacade.AddNewAddressToPerson

Pattern

Page 16: Patterns fro distributed systems

20

ISEP/IPP

Data Transport Object

An object that carries data between

processes in order to reduce the number

of method calls.

fonte: Patterns of Enterprise Application Architecture

Pattern

Page 17: Patterns fro distributed systems

21

ISEP/IPP

Data Transport Object

Since XML is the de facto standard DTO should supportserialization to/from XML

Should be independent of the underlying domain object

Should be implemented in accordance with the requiremnts ofthe remote application CompleteCustomerInfoDTO

BasicCustomerInfoDTO

Should be independent of the underlying platform (e.g., programming language) DataSet/DataTable .net

ResultSet JDBC

DateTime .net

Pattern

Page 18: Patterns fro distributed systems

22

ISEP/IPP

Service Layer

Defines an application's boundary with a layer of

services that establishes a set of available operations

and coordinates the application's response in each

operation

fonte: Patterns of Enterprise Application Architecture

Pattern

Page 19: Patterns fro distributed systems

Service Layer

Domain logic pattern in the context of

service orientation

May be implemented as a Remote

Facade or may be called by a Remote

Facade

23

ISEP/IPP

Pattern

Page 20: Patterns fro distributed systems

Service locator

Hides the complexity of finding and

creating service gateways

24

ISEP/IPP fonte: Core J2EE Patterns

Page 21: Patterns fro distributed systems

Business Logic

Outside of the scope

Excellent reference: Patterns of EnterpriseApplication Architecture Table Module

Table Data Gateway

Domain Model

Active Record

Data Mapper

Optimistic Offline Lock

28

ISEP/IPP

Page 22: Patterns fro distributed systems

SERVICE ORIENTATION

29

ISEP/IPP

Page 23: Patterns fro distributed systems

Definitions

Contract

A funcionality provided by a party

Service

An endpoint that fullfills one or more

contracts

Service Orientation

An architectural paradigm that employs the

four tennets

30

ISEP/IPP

Page 24: Patterns fro distributed systems

The four tennets of SO

Boundaries are explicit

Share schema and contract not types

Policy define service compatibility

Services are autonomous

31

ISEP/IPP

Page 25: Patterns fro distributed systems

Boundaries are explicit

Service boundaries are explicit and the

cost of crossing a boundary is “known”

A boundary is the border between the

service public interface and its internal

implementation

Services interact intentionaly and

explicitly by exchanging messages

32

ISEP/IPP

Page 26: Patterns fro distributed systems

Share schema and

contract not types

Services expose schemas defining data

structures and contracts defining

available operations

Contracts and schema may be

independently versioned over time

33

ISEP/IPP

Page 27: Patterns fro distributed systems

Policy define service

compatibility

Policy is the statement of communication

requirements necessary for service

interaction

Service capabilities and requirements are

expressed in terms of a policy expression

A policy can contain multiple assertions

34

ISEP/IPP

Page 28: Patterns fro distributed systems

Services are autonomous

Services are independently deployed,

versioned and managed

Autonomy ≠ Independence

Topology of a system evolves over time

Unlike OO, services do not share

behavior

Services gracefully handle failure

35

ISEP/IPP

Page 29: Patterns fro distributed systems

Service Anti-patterns

CRUDy interface

Design the same old CRUD interface

verbose

Loosey-Goosey

Design highly flexible interface

E.g., Expose direct SQL access

In the intent to provide flexibility, there is no

service contract

36

ISEP/IPP

Page 30: Patterns fro distributed systems

Service Patterns

Document Processor

Provide a document centric contract, not an

RPC-like contract

Reservation

Allow for long running transactions without

locking

Must have compensation procedure

37

ISEP/IPP

Page 31: Patterns fro distributed systems

Exercise

Remember the example DS you provided in the last session.

Define an hypothetical SOA for that system Define contract

Identify where you would use the presented patterns

38

ISEP/IPP

Page 32: Patterns fro distributed systems

Bibliography

Buschmann, F.; Henney, K. And Schmidt, D. (2007) Pattern-Oriented Software Architecture: A Pattern Language for Distributed Computing, Volume 4. Willey.

Patterns of Enterprise Application Architecture. Martin Fowler. Adisson-Wesley.

Core J2EE Patterns: Best Practices and Design Strategies. Deepak Alur, John Crupi and Dan Malks. Prentice Hall / Sun Microsystems Press. http://java.sun.com/blueprints/corej2eepatterns/index.html

Enterprise Solution Patterns Using Microsoft .NET. Microsoft Press. http://msdn.microsoft.com/architecture/patterns/default.aspx?pull=/library/en-us/dnpatterns/html/Esp.asp

39

ISEP/IPP

Page 33: Patterns fro distributed systems

Suggested readings

Design patterns : elements of reusable object-oriented software. Erich Gamma, Richard Helm, Ralph Johnson, John Vissides.

Pattern-oriented Software Architecture: System of Patterns. Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, Michael Stal

Designing Data Tier Components and Passing Data Through

Tiers. Microsoft Patterns & Practices.

http://msdn.microsoft.com/library/?url=/library/en-

us/dnbda/html/BOAGag.asp?frame=true

40

ISEP/IPP