Joan Martinez-Alier (ICTA-UAB). Environmental Justice, Liabilities and Trade.
ICTA Technology Meetup 06 - Enterprise Application Design Patterns
-
Upload
crishantha-nanayakkara -
Category
Technology
-
view
332 -
download
4
description
Transcript of ICTA Technology Meetup 06 - Enterprise Application Design Patterns
![Page 1: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/1.jpg)
ICTA Technology Meetup 06ICTA Technology Meetup 06
Enterprise ApplicationDesign Patterns
(Part 01)
By Crishantha Nanayakkara
![Page 2: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/2.jpg)
2
AgendaEnterprise Design Patterns – An Introduction
Enterprise Design Pattern Catalogs
Gang Of Four (GOF) Patterns
What Next? Enterprise Application Architecture Design Patterns
![Page 3: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/3.jpg)
3
Design PatternsDesign PatternsAn IntroductionAn Introduction
![Page 4: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/4.jpg)
4
![Page 5: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/5.jpg)
5
● “The gap between the best software engineering practice and the average practice is very wide – perhaps wider than the other engineering ”
– Fred Brooks (A famous author, ACM award winner)
![Page 6: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/6.jpg)
6
What is a Pattern?
This means, a This means, a Design PatternDesign Pattern gives you a solution to a gives you a solution to a common common recurringrecurring design problem design problem
However,However,
The Design Patterns are not meant to be laws or rules; The Design Patterns are not meant to be laws or rules; they are just guidelines that you can even alter to fit to they are just guidelines that you can even alter to fit to your needsyour needs
![Page 7: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/7.jpg)
7
How to create your own design pattern?
● Firstly, get the complete design pattern catalog and get familiar with them
● If you find a new pattern, then apply,
The Rule of ThreePattern can be called a pattern if it has been applied in real
world solution by at least three times
![Page 8: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/8.jpg)
8
OO vs Design Patterns
● Knowing the OO basics (abstraction, encapsulation, inheritance, polymorphism) will not make you a good designer!!!
Oh!!!What should
I do then?
![Page 9: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/9.jpg)
9
OO vs Design Patterns
● Patterns show you how to build systems with good OO design qualities
● Patterns do not give you code. They give general solutions to design problems
● Patterns are not invented they are discovered
![Page 10: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/10.jpg)
10
Are patterns always great?● NO
– Patterns are a tool, which only be used when it is needed
– Heavy use of patterns will lead to complexity
– Design patterns can be used as a shared vocabulary for communicating the design to others irrespective of the programming language
![Page 11: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/11.jpg)
11
What are anti-patterns?● If a design pattern gives you a general
solution to a recurring problem in a particular context then what does an anti-pattern give u?– An anti-pattern tells you how to go from a
problem to a BAD solution
● Why worry about finding anti-patterns?– To prevent other developers from making the
same mistake
![Page 12: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/12.jpg)
12
(Reference: as3dp.com)
![Page 13: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/13.jpg)
13
Enterprise Design Enterprise Design Pattern CatalogsPattern Catalogs
![Page 14: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/14.jpg)
14
GOF Design Patterns
Enterprise Application ArchitectureDesign Patterns
Enterprise Integration Design Patterns
SOA Patterns
Cloud Patterns
Security Patterns
![Page 15: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/15.jpg)
15
What are Pattern Catalogs?The much formal way of specifying pattern descriptionsThe much formal way of specifying pattern descriptions
The first and the The first and the most definite most definite Fundamental Design Pattern Design Pattern Catalog is Catalog is GOFGOF
(There are 23 (There are 23 fundamental fundamental patterns in it!!)patterns in it!!)
Design Patterns: Elements of Reusable Object-Oriented Software (Addison-Wesley, 1995)
![Page 16: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/16.jpg)
16
Gang of Four (GOF) Design Patterns Catalog
![Page 17: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/17.jpg)
17
Enterprise Application Architecture Patterns Catalog
(http://martinfowler.com/eaaCatalog)
![Page 19: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/19.jpg)
19
GOF Design PatternsGOF Design PatternsAn IntroductionAn Introduction
![Page 20: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/20.jpg)
20
![Page 21: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/21.jpg)
21
Behavioural PatternsBehavioural Patterns
![Page 22: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/22.jpg)
22
GOF Design Pattern Organization
![Page 23: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/23.jpg)
23
GOF Design Pattern Relationships
![Page 24: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/24.jpg)
24
Strategy Pattern
● Design Principle 1
Identify the aspects of your application that vary and separate them from what stays the same
● Design Principle 2
Program to an interface not to an implementation
● Design Principle 3
Favor composition over inheritance
![Page 25: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/25.jpg)
25
Strategy Pattern
![Page 26: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/26.jpg)
26
Strategy Pattern
![Page 27: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/27.jpg)
27
Strategy Pattern
Reference: Head First Design Patterns
![Page 28: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/28.jpg)
28Reference: Head First Design Patterns
![Page 29: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/29.jpg)
29Reference: Head First Design Patterns
![Page 30: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/30.jpg)
30
The Observer Pattern
Subject
Observer 1
Observer 2
Observer 3
Unsubscribed
Subscribers
Publisher
●When the in Subject changes, subscribers are notified●The observers are subscribed to the Subject to receive updates when the Subject data changes
![Page 31: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/31.jpg)
31
ConcreteCommand
Objects
Invoker Receiver
Command Pattern
![Page 32: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/32.jpg)
32
Creational PatternsCreational Patterns
![Page 33: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/33.jpg)
33
Singleton Pattern
However, the synchronization is bit expensive
This overcomes the multiple threading issue.
This way is good if the performance is not an issue
![Page 34: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/34.jpg)
34
The Simple Factory
![Page 35: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/35.jpg)
35
The Simple Factory
![Page 36: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/36.jpg)
36
Simple Factory
![Page 37: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/37.jpg)
37
The Factory MethodThe factory method pattern encapsulates the object
creation by letting subclasses to decide what objects to create
![Page 38: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/38.jpg)
38
The Factory Method
Factory objects are createdthrough INHERITANCE
This is the “Factory Method”
![Page 39: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/39.jpg)
39
Dependency Inversion Principle
● Before Factory Method ● After Factory Method
This is all about reducing dependencies to concrete classes in our code
Abstract Class
Concrete Classes
Though this principle is quite similar to “Program to an interface” principle, this makes a bigger statement
![Page 40: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/40.jpg)
40
Structural PatternsStructural Patterns
![Page 41: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/41.jpg)
41
Decorator Pattern
![Page 42: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/42.jpg)
42
Decorator Pattern
![Page 43: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/43.jpg)
43
Cannot Connect
Can Connect
Decorator Pattern
![Page 44: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/44.jpg)
44
Decorator Pattern
![Page 45: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/45.jpg)
45
“Adapter is used when you have an abstract interface, and you want to map that interface to another object, which has similar functional role, but a different interface”
Basically it is used to Convert the interface of an object into something else
Adapter vs Decorator Pattern
● Adapter Pattern
![Page 46: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/46.jpg)
46
“Decorator is used to extend the functionality of an object while maintaining its own interface”
● Decorator Pattern
Since both “Decorator” and “Adapter” patterns are used to “wrap” objects, they are basically known as “Wrapper Patterns”
![Page 47: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/47.jpg)
47
Facade Pattern
![Page 48: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/48.jpg)
48
Facade Pattern● Facades don’t encapsulate the sub system
classes
● They provide a simplified interface to their functionality
● The sub system classes still remain for direct access to outside clients
● One sub system can have any number of facades linked to it
● Decouples the client from a sub system – If you change any of the sub systems, your client code does not need to change.
![Page 49: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/49.jpg)
49
Facade Pattern
● Design Principle
The principle of least knowledge
Talk only to your immediate friends
This prevents us from creating a large number of classes coupled together. Having too many dependencies creates a fragile design
![Page 50: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/50.jpg)
50
● There are different kinds of proxy types
● The above is called the “Remote Proxy”
● The “Remote Proxy” acts as a local representative for an remote object. A method call on an “Remote Proxy” results the call being transferred on the wire and the result is returned back to the proxy and to the client
Proxy Pattern Remote Proxy
![Page 51: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/51.jpg)
51
● The “client object” acts like its making remote calls. ● The “proxy object” pretends to be like the “remote object”● Actually what happens is, the “client object” calls methods in the “proxy object” (in its local heap), which handles all low level details of communication
Proxyobject
Clientobject
RemoteobjectRemote call
Local heap Remote heap
![Page 52: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/52.jpg)
52
Composites
Leaf Nodes
Composite Pattern
![Page 53: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/53.jpg)
53
MenuComponent
MenuItem
Menu
MenuItems
Composite Pattern
![Page 54: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/54.jpg)
54
All components must implement the MenuComponent interface;
Why? In order for the composite to work transparently to the client, you must implement the same interface for all objects in the composite
Sometimes, the best possible way is to throw Run-time Exceptions to all unrelated methods
Composite Pattern
![Page 55: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/55.jpg)
55
The MenuComponent
Both Menu andMenuItem components should implement this interface
Having default implementation will be difficult for each method
Hence, exceptions are thrown if any invalid method is called through a component
MenuItem
Menu
Com
mon
![Page 56: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/56.jpg)
56
![Page 57: ICTA Technology Meetup 06 - Enterprise Application Design Patterns](https://reader030.fdocuments.us/reader030/viewer/2022020217/54b7aad14a79590e468b4598/html5/thumbnails/57.jpg)
57