SlideShare ist ein Scribd-Unternehmen logo
1 von 121
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
1 
Training objectives 
Duration: 3 hours 
Purpose: In the course, student will learn to: 
 Understanding the design principles. 
 Understanding the design patterns. 
 How to apply basic patterns. 
Attendees : DEVs & Designers 
Test: N/A
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
2 
OOD Principles and Patterns 
Instructor: Tung.Nguyen 
Author: tungnq@fsoft.com.vn
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
3 
Training Agenda 
•Introduce 
•Design Principles 
•Design Patterns 
•Q&A
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
4 
How Do You Design? 
What principles guide you when you create a design? 
What considerations are important? 
When have you done enough design and can begin implementation? 
Take a piece of paper and write down two principles that guide you - considerations that are important or indicators that you have a good design.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
5 
Design Level 
Architectures/Framework (Financial System, J2EE,…) 
OOD Patterns 
OOD Principles 
Specific Data Structures 
Algorithmic Approaches 
General + OO Concepts
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
6 
Major Topics in Design 
Principles of Object-Oriented Design 
Principles of Package Architecture 
Basic Patterns 
Catalog of GoF Patterns 
Other Micro-Architecture Patterns 
Concurrency Patterns 
Patterns-Oriented Software Architecture 
Catalog of J2EE Patterns 
Enterprise Integration Patterns
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
7 
Key Design Concepts 
General 
•Cohesion 
•Coupling 
•Information hiding 
•Encapsulation 
•Creation 
•Binding time 
OO Specific 
•Behaviors follow data 
•Class vs. Interface Inheritance 
•Class = implementation 
•Interface = type 
•Inheritance / composition / delegation
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
8 
UML Notation Overview 
http://www.uml.org/
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
9 
What’s Purpose Of Design? 
What’s a design? 
 Express a idea to resolve a problem. 
 Use for communications in the team members. 
What’s a good design? 
“Cohesion and Coupling deal with the quality of an OO design” 
 Easy for Developing, reading & understanding. 
 Easy for Communication. 
 Easy for Extending (add new features) 
 Easy for Maintenance. 
 “Loose coupling and high cohesion” idea!!!
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
10 
Cohesion and Coupling 
Coupling 
Coupling or Dependency is the degree to which each program module relies on each one of the other modules. 
Cohesion 
Cohesion refers to the degree to which the elements of a module belong together. Cohesion is a measure of how strongly- related or focused the responsibilities of a single module are. 
class Coupling «interface» IProductApplicationProduct AProduct BService BService ALoosely coupledwhat's happen when changing Service A --> Service B?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
11 
Symptoms of Rotting Design 
Rigidity: It is hard to change because every change affects too many other parts of the system. 
Fragility: Closely related to rigidity is fragility. When you make a change, unexpected parts of the system break. 
Immobility: It is hard to reuse in another application because it cannot be disentangled from the current application.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
12 
Training Agenda 
•Introduce 
•Design Principles 
•Basic Design Patterns 
•Q&A
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
13 
Principles of OO Class Design 
5 Principles of OO Class Design 
SRP: The Single Responsibility Principle 
OCP: The Open Closed Principle 
LSP: The Liskov Substitution Principle 
ISP: The Interface Segregation Principle 
DIP: The Dependency Inversion Principle
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
14 
Principles of OO Class Design SRP: The Single Responsibility Principle 
“There should never be more than one reason for a class to change” 
Or 
“A class should have one, and only one type of responsibility.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
15 
Principles of OO Class Design SRP: The Single Responsibility Principle (cont) 
Sample: Consider the following Rectangle class 
Two applications are using this Rectangle class: 
Computational Geometry Application uses this class to calculate the Area 
Graphical Application uses this class to draw a Rectangle in the UI
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
16 
Principles of OO Class Design SRP: The Single Responsibility Principle (cont) 
This violates SRP design principle as the Rectangle class has two responsibilities: 
 It calculates the value of the Rectangular area. 
 It renders the Rectangle in the UI. 
So, what is the problem? 
 We must include the GUI in the computational geometry application. While deployment of the geometry application, we must include GUI library. 
A change to the Rectangle class for Graphical application may lead to change, build and test the Computational geometry application.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
17 
Principles of OO Class Design SRP: The Single Responsibility Principle (cont) 
A better design is to separate the two responsibilities into two completely different classes 
Why is it important to separate these two responsibilities into separate classes?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
18 
Principles of OO Class Design SRP: The Single Responsibility Principle (cont) 
What is a Responsibility? 
“Responsibility” is defined as “a reason for change”. 
“Modem” sample 
 dial & hangup functions for managing connection 
 send & recv functions for data communication 
 Should separate into 2 repositories!
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
19 
Principles of OO Class Design OCP: The Open Closed Principle 
“Software entities(classes, modules, functions, etc.) should be open for extension, but closed for modification.” - Bertrand Meyer, 1988 
Or 
“You should be able to extend a classes behavior, without modifying code” 
“Open for extension” 
This means that the behavior of the module/class can be extended and we can make the module behave in new and different ways as the requirements changes, or to meet the needs of new applications 
“Closed for Modification” 
The source code of such a module is inviolate. No one is allowed to make source code changes to it
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
20 
Principles of OO Class Design OCP: The Open Closed Principle (cont) 
Sample: Doesn’t support Open-Close Principle 
Client & Server classes are concrete. 
If the Server implementation/class is changed, Client also needs change. 
 How to resolve this problem?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
21 
Principles of OO Class Design OCP: The Open Closed Principle (cont) 
Change to support Open-Closed Principle. 
Abstracion is the key. 
The Concrete Server class implements 
the Abstract Server class. 
The Server implementation is changed, 
the Client is likely not to require any change. 
The Abstract Server class here is closed for modification and the Concrete class implementations here are Open for extension.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
22 
Principles of OO Class Design LSP: The Liskov Substitution Principle 
“Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.” 
Or 
“Subclasses should be substitutable for their base classes.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
23 
Principles of OO Class Design LSP: The Liskov Substitution Principle (cont) 
the KingFisher class extends the Bird base class and hence, inherits the Fly() method. 
Ostrich is also a Bird (Definitely it is!) and hence it inherits the Bird class. Now, can it fly? No! Here the design violates the LSP. 
 So, even if in real world this seems natural, in the class design, Ostrich should not inherit the Bird class and there should be a separate class for birds that can’t really fly and Ostrich should inherit that.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
24 
Principles of OO Class Design LSP: The Liskov Substitution Principle (cont) 
In basic Object Oriented Principle, “Inheritance” is usually described as an "is a" relationship. 
Such “Is a” relationship is very important in class designs, but, its easy to get carried away and end up in wrong design with bad inheritance. 
 The “Liskov Substitution Principle” is a way of ensuring that inheritance is used correctly.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
25 
Principles of OO Class Design LSP: The Liskov Substitution Principle (cont) 
Why The LSP is so important? 
 If LSP is not maintained, class hierarchies would be a mess and if subclass instance was passed as parameter to methods method, strange behavior might occur. 
 If LSP is not maintained, unit tests for the Base classes would never succeed for the subclass. 
LSP is just an extension of Open-Close Principle!!!
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
26 
Principles of OO Class Design ISP: The Interface Segregation Principle 
“Client should not be forced to depend upon interface that they do not use.” 
Or 
“Many client specific interfaces are better than one general purpose interface.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
27 
Principles of OO Class Design ISP: The Interface Segregation Principle (cont) 
Sample: Providing service for Client A,B,C 
{Applying ISP}
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
28 
Principles of OO Class Design ISP: The Interface Segregation Principle (cont) 
Interfaces with too many methods are less re-usable. 
Such "fat interfaces“ with additional useless methods lead to inadvertent coupling between classes. 
Doing this also introduce unnecessary complexity and reduces maintainability or robustness in the system. 
The ISP ensures that, Interfaces are developed so that, each of them have their own responsibility and thus they are re-usable.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
29 
Principles of OO Class Design DIP: The Dependency Inversion Principle 
“High level modules should not depend upon low level modules. Both should depend upon abstractions” 
Or 
“Abstractions should not depend upon details. Details should depend upon abstraction.” 
Or 
“Depend upon Abstractions. Do not depend upon concretions.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
30 
Principles of OO Class Design DIP: The Dependency Inversion Principle (cont) 
The DIP is the strategy of depending upon interfaces or abstract functions and classes, rather than upon concrete functions and classes. 
The DIP describes the overall structure of a well designed object-oriented application. 
Sample: Layers of application
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
31 
6 Principles of Package Architecture 
3 The Package Cohesion Principles 
REP: The Release/Reuse Equivalency Principle 
CRP: The Common Reuse Principle 
CCP: The Common Closure Principle 
3 The Package Coupling Principles 
ADP: The Acyclic Dependencies Principle 
SDP: The Stable Dependencies Principle 
SAP: The Stable Abstractions Principle
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
32 
Why? 
When software application grows in size and complexity  they require some kind of high level organization. 
Applying for large application.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
33 
Design with Packages 
Packages can be used as containers for a group of classes: 
 The design at a high level of abstraction. 
The relationships between those packages expresses the high level organization of the application 
Question for package design? 
What are the best grouping criteria? 
What are the relationships that exist between packages, and what design principles govern their use? 
Should packages be designed before classes (Top down)? Or should classes be designed before packages (Bottom up)? 
How are packages physically represented? 
Once created, to what purpose will we put these packages?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
34 
The Package Cohesion Principles REP: The Release/Reuse Equivalency Principle 
“The granule of reuse is the granule of release. Only components that are released through a tracking system can be effectively reused. This granule is the package.” 
Or 
“The granule of reuse is the granule of release. Anything that it is reused must also be released”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
35 
The Package Cohesion Principles REP: The Release/Reuse Equivalency Principle 
Packages are a candidate for a releasable entity. 
Packages might be possible to release and track classes (release version).
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
36 
The Package Cohesion Principles CRP: The Common Reuse Principle 
“The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all.” 
Or 
“Classes that are used together are packaged together.” 
Or 
“Classes that aren’t reused together should not be grouped together.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
37 
The Package Cohesion Principles CRP: The Common Reuse Principle 
A dependency upon a package is a dependency upon everything within the package. 
Which classes should be placed into a package? 
Generally reusable classes collaborate with other classes that are part of the reusable abstraction  These classes belong together in the same package.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
38 
The Package Cohesion Principles CCP: The Common Closure Principle 
“The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.” 
Or 
“Classes that change together are packaged together.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
39 
The Package Cohesion Principles CCP: The Common Closure Principle 
More important than reusability, is maintainability. 
What’s happen when application must change code?  changing at: all in one package, or distributed through many packages? 
All classes having the same changing reason must belong in the same package 
 This minimizes the workload related to releasing, revalidating, and redistributing the software.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
40 
The Package Cohesion Principles Review 
The REP and CRP makes life easy for reuse. 
The CCP makes life easier for maintenance. 
The CCP strives to make packages as large as possible. 
The CRP tries to make packages very small.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
41 
6 Principles of Package Architecture 
3 The Package Cohesion Principles 
REP: The Release/Reuse Equivalency Principle 
CRP: The Common Reuse Principle 
CCP: The Common Closure Principle 
3 The Package Coupling Principles 
ADP: The Acyclic Dependencies Principle 
SDP: The Stable Dependencies Principle 
SAP: The Stable Abstractions Principle
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
42 
The Package Cohesion Principles ADP: The Acyclic Dependencies Principle 
“The dependency structure between packages must be a directed acyclic graph (DAG). That is, there must be no cycles in the dependency structure.” 
Or 
“The dependencies between packages must not form cycles.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
43 
The Package Cohesion Principles ADP: The Acyclic Dependencies Principle 
Sample: Acyclic Package Network 
 What happen when releasing Protocol package? 
•Build with latest CommError package. 
•Run & Test Protocol package. 
Test & Release with minimal 
amount of work.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
44 
The Package Cohesion Principles ADP: The Acyclic Dependencies Principle 
Sample: A Cycle Creeps In 
CommError can display error msg on GUI. What happen when Protocol package?  Build & Test everything!!!
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
45 
The Package Cohesion Principles ADP: The Acyclic Dependencies Principle 
Sample: Breaking Cycle 
There are 2 ways to break cycle: 
-Creating new package. 
-Make use of DIP and ISP. 
Both GUI & CommError packages depend upon one new package Message Manager
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
46 
The Package Cohesion Principles ADP: The Acyclic Dependencies Principle 
Sample: Breaking Cycle 
Using “BY” interface. 
There are 2 ways to break cycle: 
-Creating new package. 
-Make use of DIP and ISP.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
47 
The Package Cohesion Principles SDP: The Stable Dependencies Principle 
“The dependencies between packages in a design should be the direction of the stability of the packages. A package should only depend upon packages that are more stable that it is” 
Or 
“Depend in the direction of stability.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
48 
The Package Cohesion Principles SDP: The Stable Dependencies Principle 
Stability is a measure of the difficulty in changing a module. 
The package is difficult to change because a lot of other packages depend upon it. 
A package with a lot of incoming dependencies is very stable because it requires a great deal of work to reconcile any changes with all the dependent packages. 
The package is more Stable  it is less Flexible.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
49 
The Package Cohesion Principles SDP: The Stable Dependencies Principle 
Package X has 3 packages depending upon it. 
 X has 3 good reasons not to change!  X is responsible to those 3 packages. 
Package Y has no other packages depending upon it 
 Y is irresponsible. 
X is a stable package 
Y is a instable package
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
50 
The Package Cohesion Principles SDP: The Stable Dependencies Principle 
Stability Matrix: is used to calculate the possible stability of the package. 
 Ca : Afferent Couplings : The number of classes outside this package that depend upon classes within this package. 
 Ce : Efferent Couplings : The number of classes inside this package that depend upon classes outside this package. 
 I : Instability : (Ce ÷(Ca+Ce)) : This metric has the range [0,1] 
•I=0 indicates a maximally stable package. 
•I=1 indicates a maximally instable package.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
51 
The Package Cohesion Principles SDP: The Stable Dependencies Principle 
Sample: Ca=4, Ce=3, and I=3/7
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
52 
The Package Cohesion Principles SDP: The Stable Dependencies Principle 
The I metric of a package should be larger than the I metrics of the packages that it depends upon. 
The I metrics should decrease in the direction of dependency. 
All the packages in a system were maximally stable (I=0), the system would be unchangeable.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
53 
The Package Cohesion Principles SAP: The Stable Abstractions Principle 
“Packages that are maximally stable should be maximally abstract. Instable packages should be concrete. The abstraction of a package should be in proportion to its stability.” 
Or 
“Stable packages should be abstract packages.” 
Or 
“Abstractness increases with stability.”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
54 
The Package Cohesion Principles SAP: The Stable Abstractions Principle 
A package is to be stable, it should also consist of abstract classes so that it can be extended. 
Stable packages that are extensible are flexible and do not constrain the design. 
The Abstractness Metrics: 
 Nc: Number of classes in package. 
 Na: Number of abstract classes in package. 
 A: Abstractness [0,1]. A= Na/Nc
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
55 
Sample: Package Diagram 
pkg Logical Architecture OverviewClient LayerPresentation LayerBusiness Logic LayerData Access LayerDatabase & External System LayerCommons LayerStruts 2.x(from Frameworks) webRichFace(from Frameworks) JSP(from Frameworks) SpringSecurity 3.x(from Frameworks) businesshibernate(from dao) email(from dao) ldap(from dao) Architecture Overview:: SMTP ServerArchitecture Overview:: Database schema Oracle 11gArchitecture Overview:: Group Directory SystemSpring Transation Manager 3.x(from Frameworks) Hibernate JPA 3.6.x(from Frameworks) schedulerSpringBatch 2.x(from Frameworks) Users(from Use Case View) modelSpring IoC 3.x(from Frameworks) utils«use» «forward» «use» «use» «use» «use» «access» «use» JDBC «access» LDAP «access» «use» «use» https«use» «dependency injection» SMTP/IMAP «access»
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
56 
Training Agenda 
•Introduce 
•Design Principles 
•Basic Design Patterns 
•Q&A
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
57 
What are Patterns? 
"Each pattern describes a problem which 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 
A pattern is a general solution to a problem in a context 
• general -- outline of approach only 
• problem -- a recurring issue 
• context -- consider the expected design evolution
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
58 
What are Patterns About? 
Standard patterns of interactions between classes 
Design patterns 
How to apply them to your application 
Deal with subsystems at the higher level of abstraction provided by the patterns 
What to do when it does not fit exactly 
Evaluate options and analyze the trade-offs
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
59 
Why Patterns? 
Design for re-use is difficult 
Experienced designers: 
Rarely start from first principles 
Apply a working "handbook" of approaches 
Patterns make this ephemeral knowledge available to all. 
Support evaluation of alternatives at higher level of abstraction.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
60 
Benefit from Design Pattern 
Design Patterns give you a shared vocabulary with other developers. 
Shared pattern vocabularies are POWERFUL. 
Patterns allow you to say more with less. 
Talking at the pattern level allows you to stay “in the design” longer. 
Shared vocabularies can turbo charge your development team. 
Shared vocabularies encourage more junior developers to get up to speed.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
61 
How To Use Design Pattern?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
62 
Basic Design Patterns 
The Strategy Pattern 
The Observer Pattern 
The Factory Pattern 
The Singleton Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
63 
The Strategy Pattern 
The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. 
Sample Project: The game can show a large variety of duck species swimming and making quacking sounds. 
Using standard OO techniques (e.g: inheritance, interface, abstract classes…) 
Using Design Pattern.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
64 
Using Standard OO Techniques
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
65 
Using Standard OO Techniques 
Needing fly for Duck???  Fail!!!
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
66 
Using Standard OO Techniques 
Using Interfaces  needing to override for every subclasses  Duplicated code!!!
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
67 
Using Design Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
68 
Using Design Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
69 
Using Design Pattern 
The key is that a Duck will now delegate its flying and quacking behavior, instead of using quacking and flying methods defined in the Duck class (or subclass).
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
70 
Using Design Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
71 
Using Design Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
72 
Design Pattern Toolbox 
OO Basic 
•Abstraction 
•Encapsulation 
•Polymorphism 
•Inheritance 
OO Principle 
•Encapsulate what varies. 
•Favor composition over inheritence. 
•Program to interfaces, not implementations. 
OO Pattern 
•Rely on OO basics and principles. 
•Strategy- defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
73 
Basic Design Patterns 
The Strategy Pattern 
The Observer Pattern 
The Factory Pattern 
The Singleton Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
74 
The Observer Pattern “ Keep your Objects in the know” 
This pattern keeps your objects in the know when something they might care about happens. Objects can even decide at runtime whether they want to be kept informed. 
Sample: Internet-based Weather Monitoring Station 
The weather station will be based on our patent pending WeatherData object, which tracks current weather conditions (temperature, humidity, and barometric pressure). 
The application is created to provides three display elements: current conditions, weather statistics and a simple forecast, all updated in real time.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
75 
The Weather Monitoring App Overview
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
76 
The Weather Monitoring App Fist implementation
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
77 
The Weather Monitoring App What is wrong in this implementation?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
78 
The Observer Pattern Idea 
Publishers + Subscribers = Observer Pattern 
The publisher the SUBJECT and the subscribers the OBSERVERS
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
79 
The Observer Pattern defined 
The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
80 
An Observer Pattern Implementation
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
81 
Benefit of Observer Pattern??? 
The Observer Pattern provides an object design where subjects and observers are loosely coupled. 
The only thing the subject knows about an observer is that it implements a certain interface. 
We can add new observers at any time. 
We never need to modify the subject to add new types of observers. 
We can reuse subjects or observers independently of each other. 
Changes to either the subject or an observer will not affect the other.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
82 
Designing the Weather Station a
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
83 
Implementing the Weather Station
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
84 
Implementing the Subject Interface
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
85 
Implementing the Observer Interface
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
86 
Design Pattern Toolbox 
OO Basic 
•Abstraction 
•Encapsulation 
•Polymorphism 
•Inheritance 
OO Principle 
•Encapsulate what varies. 
•Favor composition over inheritence. 
•Program to interfaces, not implementations. 
•Strive for loosely coupled designs between objects that interact 
OO Pattern 
•Rely on OO basics and principles. 
•Observer- defines a one- to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
87 
Observer Pattern Highlight!!! 
The Observer Pattern defines a one-to-many relationship between objects. 
Subjects, or as we also know them, Observables, update Observers using a common interface. 
Observers are loosely coupled in that the Observable knows nothing about them, other than that they implement the Observer Interface. 
You can push or pull data from the Observable when using the pattern (pull is considered more “correct”). 
Don’t depend on a specific order of notification for your Observers.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
88 
Design Principle Challenge 
Identify the aspects of your application that vary and separate them from what stays the same. 
Program to an interface, not an implementation. 
Favor composition over inheritance.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
89 
Basic Design Patterns 
The Strategy Pattern 
The Observer Pattern 
The Factory Pattern 
The Singleton Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
90 
4. The Factory Pattern “Baking with OO Goodness” 
Get ready to bake some loosely coupled OO designs. 
There is more to making objects than just using the new operator. 
The ways to create objects 
Simple Factory/Static Factory 
Factory Method Pattern 
•Dependency Injection (DI) 
Abstract Factory Pattern 
When you see “new”, think “concrete”.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
91 
Sample Code “Creation a Duck instance” 
What’s happen when updating or extending the code? 
Open the code and examine what needs to be added or deleted. 
This kind of code ends up is several parts of the application making maintenance and update more difficult and error –prone.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
92 
Pizza Making Order “Support: CheesePizza, GreekPizza, PepperoniPizza”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
93 
Pizza Making Order “What’s happen when adding more pizza type?” 
Messing up on orderPizza() method???
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
94 
Encapsulating Object Creation “Simple Factory/Static Factory”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
95 
Pizza Making Order “With Simple Factory”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
96 
The Simple Factory Defined 
The Simple Factory isn’t actually a Design Pattern; it’s more of a programming idiom. 
 But it is commonly used
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
97 
Extending for Pizza Store
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
98 
Factory Method Pattern 
The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
99 
New Pizza Store “Applying Factory Method Pattern”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
100 
New Pizza Store “Applying Factory Method Pattern”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
101 
New Pizza Store “Applying Factory Method Pattern”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
102 
The Dependency Inversion Principle 
Design Principle: Depend upon abstractions (interface, abstract, or super classes). Do not depend upon concrete classes. 
This principle is similar with “Program to an interface, not an implementation”.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
103 
Abstract Factory Pattern 
The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
104 
New PizzaStore... “Applying Abstract Factory Pattern” 
All Objectville’s Pizzas are made from the same components, but each region has a different implementation of those components.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
105 
New PizzaStore... “Applying Abstract Factory Pattern”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
106 
PizzaStore Class Diagram
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
107 
Factory Method & Abstract Factory Compared!!!
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
108 
Design Pattern Toolbox 
OO Basic 
•Abstraction 
•Encapsulation 
•Polymorphism 
•Inheritance 
OO Principle 
•Encapsulate what varies. 
•Favor composition over inheritence. 
•Program to interfaces, not implementations. 
•Depend on abstractions. Do not depend on concrete classes. 
OO Pattern 
•Rely on OO basics and principles. 
•Factory Method- Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to the subclasses. 
•Abstract Factory- Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
109 
Factory Pattern Highlight!!! 
All factories encapsulate object creation. 
Simple Factory, while not a bona fide design pattern, is a simple way to decouple your clients from concrete classes. 
Factory Method relies on inheritance: object creation is delegated to subclasses which implement the factory method to create objects. 
Abstract Factory relies on object composition: object creation is implemented in methods exposed in the factory interface. 
All factory patterns promote loose coupling by reducing the dependency of your application on concrete classes. 
The intent of Factory Method is to allow a class to defer instantiation to its subclasses. 
The intent of Abstract Factory is to create families of related objects without having to depend on their concrete classes. 
The Dependency Inversion Principle guides us to avoid dependencies on concrete types and to strive for abstractions. 
Factories are a powerful technique for coding to abstractions, not concrete classes
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
110 
Basic Design Patterns 
The Strategy Pattern 
The Observer Pattern 
The Factory Pattern 
The Singleton Pattern
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
111 
5. The Singleton Pattern “One of a Kind Objects” 
There is ONE and ONLY ONE object/instance to serve all requests. 
There are many objects, the program will run into all sorts of problems like incorrect behavior, overuse of resource, or inconsistent results (e.g: Thread Pools, Caches, Dialog Boxes, Object that handle preferences and registry setting, objects used for logging,…)
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
112 
The Singleton Pattern “A Implementation”
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
113 
Singleton Pattern Defined 
The Singleton Pattern ensures a class has only one instance, and provides a global point of access to it. 
The class will manage a single instance of itself. 
The class prevents any other class from creating a new instance on its own. 
The class provides a global access point to the instance.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
114 
Dealing with Multithreading 
Using synchronized keyword to avoid dead lock in multi-threading.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
115 
Design Pattern Toolbox 
OO Basic 
•Abstraction 
•Encapsulation 
•Polymorphism 
•Inheritance 
OO Principle 
•Encapsulate what varies. 
•Favor composition over inheritence. 
•Program to interfaces, not implementations. 
OO Pattern 
•Rely on OO basics and principles. 
•Singleton- Ensure a one instance and provide a global point of access to it.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
116 
Singleton Pattern Highlight!!! 
The Singleton Pattern ensures you have at most one instance of a class in the application. 
The Singleton Pattern also provides a global access point to that instance. 
Java’s implementation of the Singleton Pattern makes use of a private constructor, a static method combined with a static variable. 
Examine your performance and resource constraints and carefully choose an appropriate Singleton implementation for multithreaded applications (and you should consider all applications multithreaded!). 
Beware of the double-checked locking implementation. 
Be careful if you are using multiple class loaders; this could defeat the Singleton implementation and result in multiple instances.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
117 
Sample: Voice Control Wrapper 
The system uses third party for voice control module. 
We plan to user other third party voice control in the future, so needing to design a wrapper package to avoid impaction when changing. 
How to do this ones?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
118 
Sample: Voice Control Wrapper Package Diagram
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
119 
Sample: Voice Control Wrapper Classes Diagram
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
120 
Basic Design Pattern Book
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 
04e-BM/NS/HDCV/FSOFT v2/4 
121 
Q & A

Weitere ähnliche Inhalte

Was ist angesagt?

Waris l2vpn-tutorial
Waris l2vpn-tutorialWaris l2vpn-tutorial
Waris l2vpn-tutorialrakiva29
 
Software services business proposal
Software services  business proposalSoftware services  business proposal
Software services business proposalAjay Tripathi
 
Maximizing SD-WAN Architecture with Service Chaining - VeloCloud
Maximizing SD-WAN Architecture with Service Chaining - VeloCloudMaximizing SD-WAN Architecture with Service Chaining - VeloCloud
Maximizing SD-WAN Architecture with Service Chaining - VeloCloudVeloCloud Networks, Inc.
 
GOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs Istio
GOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs IstioGOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs Istio
GOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs IstioNicolas Fränkel
 
Chassis Cluster Configuration
Chassis Cluster ConfigurationChassis Cluster Configuration
Chassis Cluster ConfigurationKashif Latif
 
F5 Solutions for Service Providers
F5 Solutions for Service ProvidersF5 Solutions for Service Providers
F5 Solutions for Service ProvidersBAKOTECH
 
MuleSoft Anypoint Platform and Three Tier Architecture
MuleSoft Anypoint  Platform and Three Tier ArchitectureMuleSoft Anypoint  Platform and Three Tier Architecture
MuleSoft Anypoint Platform and Three Tier ArchitectureHarish Kumar
 
Demystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode seriesDemystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode seriesCumulus Networks
 
DevOps Days Kyiv 2019 -- Victoria Metrics // Artem Navoiev
DevOps Days Kyiv 2019 -- Victoria Metrics // Artem NavoievDevOps Days Kyiv 2019 -- Victoria Metrics // Artem Navoiev
DevOps Days Kyiv 2019 -- Victoria Metrics // Artem NavoievMykola Marzhan
 
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys MeetupsMuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys MeetupsAngel Alberici
 
Vanrish Mulesoft Integration architect ppt
Vanrish Mulesoft Integration architect pptVanrish Mulesoft Integration architect ppt
Vanrish Mulesoft Integration architect pptRajnish Kumar
 
Cisco nexus series
Cisco nexus seriesCisco nexus series
Cisco nexus seriesAnwesh Dixit
 
MP BGP-EVPN 실전기술-1편(개념잡기)
MP BGP-EVPN 실전기술-1편(개념잡기)MP BGP-EVPN 실전기술-1편(개념잡기)
MP BGP-EVPN 실전기술-1편(개념잡기)JuHwan Lee
 
Element Management Subsystem
Element Management SubsystemElement Management Subsystem
Element Management Subsystemdevalnaik
 
Micro vs Nano (servicios)
Micro vs Nano (servicios)Micro vs Nano (servicios)
Micro vs Nano (servicios)Pedro J. Molina
 

Was ist angesagt? (20)

Waris l2vpn-tutorial
Waris l2vpn-tutorialWaris l2vpn-tutorial
Waris l2vpn-tutorial
 
Software services business proposal
Software services  business proposalSoftware services  business proposal
Software services business proposal
 
Maximizing SD-WAN Architecture with Service Chaining - VeloCloud
Maximizing SD-WAN Architecture with Service Chaining - VeloCloudMaximizing SD-WAN Architecture with Service Chaining - VeloCloud
Maximizing SD-WAN Architecture with Service Chaining - VeloCloud
 
GOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs Istio
GOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs IstioGOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs Istio
GOTO Berlin - Battle of the Circuit Breakers: Resilience4J vs Istio
 
Chassis Cluster Configuration
Chassis Cluster ConfigurationChassis Cluster Configuration
Chassis Cluster Configuration
 
Mulesoft ppt
Mulesoft pptMulesoft ppt
Mulesoft ppt
 
F5 Solutions for Service Providers
F5 Solutions for Service ProvidersF5 Solutions for Service Providers
F5 Solutions for Service Providers
 
Doc6 mpls vpn-ppt
Doc6 mpls vpn-pptDoc6 mpls vpn-ppt
Doc6 mpls vpn-ppt
 
MuleSoft Anypoint Platform and Three Tier Architecture
MuleSoft Anypoint  Platform and Three Tier ArchitectureMuleSoft Anypoint  Platform and Three Tier Architecture
MuleSoft Anypoint Platform and Three Tier Architecture
 
Introduction to Docker on AWS
Introduction to Docker on AWSIntroduction to Docker on AWS
Introduction to Docker on AWS
 
Demystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode seriesDemystifying EVPN in the data center: Part 1 in 2 episode series
Demystifying EVPN in the data center: Part 1 in 2 episode series
 
DevOps Days Kyiv 2019 -- Victoria Metrics // Artem Navoiev
DevOps Days Kyiv 2019 -- Victoria Metrics // Artem NavoievDevOps Days Kyiv 2019 -- Victoria Metrics // Artem Navoiev
DevOps Days Kyiv 2019 -- Victoria Metrics // Artem Navoiev
 
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys MeetupsMuleSoft Runtime Fabric (RTF): Foundations  : MuleSoft Virtual Muleys Meetups
MuleSoft Runtime Fabric (RTF): Foundations : MuleSoft Virtual Muleys Meetups
 
Vanrish Mulesoft Integration architect ppt
Vanrish Mulesoft Integration architect pptVanrish Mulesoft Integration architect ppt
Vanrish Mulesoft Integration architect ppt
 
Cisco nexus series
Cisco nexus seriesCisco nexus series
Cisco nexus series
 
MP BGP-EVPN 실전기술-1편(개념잡기)
MP BGP-EVPN 실전기술-1편(개념잡기)MP BGP-EVPN 실전기술-1편(개념잡기)
MP BGP-EVPN 실전기술-1편(개념잡기)
 
VLAN vs VXLAN
VLAN vs VXLANVLAN vs VXLAN
VLAN vs VXLAN
 
VXLAN
VXLANVXLAN
VXLAN
 
Element Management Subsystem
Element Management SubsystemElement Management Subsystem
Element Management Subsystem
 
Micro vs Nano (servicios)
Micro vs Nano (servicios)Micro vs Nano (servicios)
Micro vs Nano (servicios)
 

Andere mochten auch

SaaS Introduction-May2014
SaaS Introduction-May2014SaaS Introduction-May2014
SaaS Introduction-May2014Nguyen Tung
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice ArchitectureNguyen Tung
 
Architecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionArchitecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionNguyen Tung
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with MavenMika Koivisto
 
J2EE Technology Mapping-21-may-2014
J2EE Technology Mapping-21-may-2014J2EE Technology Mapping-21-may-2014
J2EE Technology Mapping-21-may-2014Nguyen Tung
 
Liferay Portal Introduction
Liferay Portal IntroductionLiferay Portal Introduction
Liferay Portal IntroductionNguyen Tung
 
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietySOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietyChris Weldon
 
bGenius kennissessie_20120510
bGenius kennissessie_20120510bGenius kennissessie_20120510
bGenius kennissessie_20120510bgenius
 
S.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developersS.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developersProf. Dr. Roland Petrasch
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesDr. Syed Hassan Amin
 
Ing. industrial tec. de culiacan
Ing. industrial  tec.  de culiacanIng. industrial  tec.  de culiacan
Ing. industrial tec. de culiacanTecnologicoCuliacan
 
Ibitgs syllabus 2011-2012
Ibitgs syllabus 2011-2012Ibitgs syllabus 2011-2012
Ibitgs syllabus 2011-2012Yvonne Mafunga
 
Rupicon 2014 solid
Rupicon 2014 solidRupicon 2014 solid
Rupicon 2014 solidrupicon
 
Beyond design patterns and principles - writing good OO code
Beyond design patterns and principles - writing good OO codeBeyond design patterns and principles - writing good OO code
Beyond design patterns and principles - writing good OO codeMatthias Noback
 
Rop clasificación pedro mattar
Rop clasificación pedro mattarRop clasificación pedro mattar
Rop clasificación pedro mattarEdwin Martinez
 
National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...
National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...
National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...Sujit Chandak
 

Andere mochten auch (20)

SaaS Introduction-May2014
SaaS Introduction-May2014SaaS Introduction-May2014
SaaS Introduction-May2014
 
Microservice Architecture
Microservice ArchitectureMicroservice Architecture
Microservice Architecture
 
Architecture Patterns - Open Discussion
Architecture Patterns - Open DiscussionArchitecture Patterns - Open Discussion
Architecture Patterns - Open Discussion
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
 
J2EE Technology Mapping-21-may-2014
J2EE Technology Mapping-21-may-2014J2EE Technology Mapping-21-may-2014
J2EE Technology Mapping-21-may-2014
 
Liferay Portal Introduction
Liferay Portal IntroductionLiferay Portal Introduction
Liferay Portal Introduction
 
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietySOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
 
bGenius kennissessie_20120510
bGenius kennissessie_20120510bGenius kennissessie_20120510
bGenius kennissessie_20120510
 
S.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developersS.O.L.I.D. Software-Engineering Principles - a must know for developers
S.O.L.I.D. Software-Engineering Principles - a must know for developers
 
Improving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design PrinciplesImproving Software Quality Using Object Oriented Design Principles
Improving Software Quality Using Object Oriented Design Principles
 
E resources
E resourcesE resources
E resources
 
Ing. industrial tec. de culiacan
Ing. industrial  tec.  de culiacanIng. industrial  tec.  de culiacan
Ing. industrial tec. de culiacan
 
Ldv tour
Ldv tourLdv tour
Ldv tour
 
Ibitgs syllabus 2011-2012
Ibitgs syllabus 2011-2012Ibitgs syllabus 2011-2012
Ibitgs syllabus 2011-2012
 
Rupicon 2014 solid
Rupicon 2014 solidRupicon 2014 solid
Rupicon 2014 solid
 
Beyond design patterns and principles - writing good OO code
Beyond design patterns and principles - writing good OO codeBeyond design patterns and principles - writing good OO code
Beyond design patterns and principles - writing good OO code
 
Rop clasificación pedro mattar
Rop clasificación pedro mattarRop clasificación pedro mattar
Rop clasificación pedro mattar
 
Itgs scheme 2011-2012
Itgs scheme 2011-2012Itgs scheme 2011-2012
Itgs scheme 2011-2012
 
SOLID Design principles
SOLID Design principlesSOLID Design principles
SOLID Design principles
 
National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...
National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...
National Literature in a Multilingual Nation. Sujit chandak pre ph d presenta...
 

Ähnlich wie FPT OOD Training on Principles and Patterns

Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic conceptsHưng Hoàng
 
Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic conceptsSuresh Mca
 
Pre-Con Education: Introduction to Mainframe Academy With CA Technologies
Pre-Con Education: Introduction to Mainframe Academy With CA TechnologiesPre-Con Education: Introduction to Mainframe Academy With CA Technologies
Pre-Con Education: Introduction to Mainframe Academy With CA TechnologiesCA Technologies
 
Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic conceptsRaju Jadhav
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsBasavaraj Patil
 
Planning for Success in MDD
Planning for Success in MDDPlanning for Success in MDD
Planning for Success in MDDSteven Kelly
 
Innovate2014 Panel - Best Practices on Implementing Integrations
Innovate2014 Panel - Best Practices on Implementing IntegrationsInnovate2014 Panel - Best Practices on Implementing Integrations
Innovate2014 Panel - Best Practices on Implementing IntegrationsSteve Speicher
 
Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...
Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...
Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...Mateescu Horatiu
 
TMF2014 Thinksoft Automation Presentation
TMF2014 Thinksoft Automation PresentationTMF2014 Thinksoft Automation Presentation
TMF2014 Thinksoft Automation PresentationKJR
 
408372362-Student-Result-management-System-project-report-docx.docx
408372362-Student-Result-management-System-project-report-docx.docx408372362-Student-Result-management-System-project-report-docx.docx
408372362-Student-Result-management-System-project-report-docx.docxsanthoshyadav23
 
[Capella Days 2020] Capella Development Status & Future Work
[Capella Days 2020] Capella Development Status & Future Work[Capella Days 2020] Capella Development Status & Future Work
[Capella Days 2020] Capella Development Status & Future WorkObeo
 
Requirements on No Requirements - When using agile is justified?
Requirements on No Requirements - When using agile is justified?Requirements on No Requirements - When using agile is justified?
Requirements on No Requirements - When using agile is justified?Ilia Bider
 
Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...
Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...
Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...Ewa Stepien
 
Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...Training Industry Conference & Expo
 
Code like a ninja session 3 open-closed principle
Code like a ninja  session 3   open-closed principleCode like a ninja  session 3   open-closed principle
Code like a ninja session 3 open-closed principleDeon Meyer
 
ITpreneurs DASA dev ops elearning - get devops certified now!
ITpreneurs DASA dev ops elearning - get devops certified now!ITpreneurs DASA dev ops elearning - get devops certified now!
ITpreneurs DASA dev ops elearning - get devops certified now!Arjan Woertman
 

Ähnlich wie FPT OOD Training on Principles and Patterns (20)

Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic concepts
 
Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic concepts
 
Pre-Con Education: Introduction to Mainframe Academy With CA Technologies
Pre-Con Education: Introduction to Mainframe Academy With CA TechnologiesPre-Con Education: Introduction to Mainframe Academy With CA Technologies
Pre-Con Education: Introduction to Mainframe Academy With CA Technologies
 
Software testing basic concepts
Software testing basic conceptsSoftware testing basic concepts
Software testing basic concepts
 
DesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatternsDesignPrinciples-and-DesignPatterns
DesignPrinciples-and-DesignPatterns
 
Planning for Success in MDD
Planning for Success in MDDPlanning for Success in MDD
Planning for Success in MDD
 
2000- Kod-Knowledge on demand
2000- Kod-Knowledge on demand2000- Kod-Knowledge on demand
2000- Kod-Knowledge on demand
 
Innovate2014 Panel - Best Practices on Implementing Integrations
Innovate2014 Panel - Best Practices on Implementing IntegrationsInnovate2014 Panel - Best Practices on Implementing Integrations
Innovate2014 Panel - Best Practices on Implementing Integrations
 
Practical DevOps
Practical DevOpsPractical DevOps
Practical DevOps
 
Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...
Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...
Oracle University - Next Generation Cloud Training Solution ( In-App Guided L...
 
TMF2014 Thinksoft Automation Presentation
TMF2014 Thinksoft Automation PresentationTMF2014 Thinksoft Automation Presentation
TMF2014 Thinksoft Automation Presentation
 
408372362-Student-Result-management-System-project-report-docx.docx
408372362-Student-Result-management-System-project-report-docx.docx408372362-Student-Result-management-System-project-report-docx.docx
408372362-Student-Result-management-System-project-report-docx.docx
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
[Capella Days 2020] Capella Development Status & Future Work
[Capella Days 2020] Capella Development Status & Future Work[Capella Days 2020] Capella Development Status & Future Work
[Capella Days 2020] Capella Development Status & Future Work
 
Requirements on No Requirements - When using agile is justified?
Requirements on No Requirements - When using agile is justified?Requirements on No Requirements - When using agile is justified?
Requirements on No Requirements - When using agile is justified?
 
Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...
Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...
Successful SaaS implementation journey, Sarkis Kerkezian, Oracle @ SaaS Day, ...
 
Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...Somewhere in the Middle: Using technology to help employees learn and do thin...
Somewhere in the Middle: Using technology to help employees learn and do thin...
 
Solid
SolidSolid
Solid
 
Code like a ninja session 3 open-closed principle
Code like a ninja  session 3   open-closed principleCode like a ninja  session 3   open-closed principle
Code like a ninja session 3 open-closed principle
 
ITpreneurs DASA dev ops elearning - get devops certified now!
ITpreneurs DASA dev ops elearning - get devops certified now!ITpreneurs DASA dev ops elearning - get devops certified now!
ITpreneurs DASA dev ops elearning - get devops certified now!
 

Kürzlich hochgeladen

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 

Kürzlich hochgeladen (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 

FPT OOD Training on Principles and Patterns

  • 1. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 1 Training objectives Duration: 3 hours Purpose: In the course, student will learn to:  Understanding the design principles.  Understanding the design patterns.  How to apply basic patterns. Attendees : DEVs & Designers Test: N/A
  • 2. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 2 OOD Principles and Patterns Instructor: Tung.Nguyen Author: tungnq@fsoft.com.vn
  • 3. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 3 Training Agenda •Introduce •Design Principles •Design Patterns •Q&A
  • 4. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 4 How Do You Design? What principles guide you when you create a design? What considerations are important? When have you done enough design and can begin implementation? Take a piece of paper and write down two principles that guide you - considerations that are important or indicators that you have a good design.
  • 5. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 5 Design Level Architectures/Framework (Financial System, J2EE,…) OOD Patterns OOD Principles Specific Data Structures Algorithmic Approaches General + OO Concepts
  • 6. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 6 Major Topics in Design Principles of Object-Oriented Design Principles of Package Architecture Basic Patterns Catalog of GoF Patterns Other Micro-Architecture Patterns Concurrency Patterns Patterns-Oriented Software Architecture Catalog of J2EE Patterns Enterprise Integration Patterns
  • 7. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 7 Key Design Concepts General •Cohesion •Coupling •Information hiding •Encapsulation •Creation •Binding time OO Specific •Behaviors follow data •Class vs. Interface Inheritance •Class = implementation •Interface = type •Inheritance / composition / delegation
  • 8. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 8 UML Notation Overview http://www.uml.org/
  • 9. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 9 What’s Purpose Of Design? What’s a design?  Express a idea to resolve a problem.  Use for communications in the team members. What’s a good design? “Cohesion and Coupling deal with the quality of an OO design”  Easy for Developing, reading & understanding.  Easy for Communication.  Easy for Extending (add new features)  Easy for Maintenance.  “Loose coupling and high cohesion” idea!!!
  • 10. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 10 Cohesion and Coupling Coupling Coupling or Dependency is the degree to which each program module relies on each one of the other modules. Cohesion Cohesion refers to the degree to which the elements of a module belong together. Cohesion is a measure of how strongly- related or focused the responsibilities of a single module are. class Coupling «interface» IProductApplicationProduct AProduct BService BService ALoosely coupledwhat's happen when changing Service A --> Service B?
  • 11. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 11 Symptoms of Rotting Design Rigidity: It is hard to change because every change affects too many other parts of the system. Fragility: Closely related to rigidity is fragility. When you make a change, unexpected parts of the system break. Immobility: It is hard to reuse in another application because it cannot be disentangled from the current application.
  • 12. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 12 Training Agenda •Introduce •Design Principles •Basic Design Patterns •Q&A
  • 13. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 13 Principles of OO Class Design 5 Principles of OO Class Design SRP: The Single Responsibility Principle OCP: The Open Closed Principle LSP: The Liskov Substitution Principle ISP: The Interface Segregation Principle DIP: The Dependency Inversion Principle
  • 14. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 14 Principles of OO Class Design SRP: The Single Responsibility Principle “There should never be more than one reason for a class to change” Or “A class should have one, and only one type of responsibility.”
  • 15. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 15 Principles of OO Class Design SRP: The Single Responsibility Principle (cont) Sample: Consider the following Rectangle class Two applications are using this Rectangle class: Computational Geometry Application uses this class to calculate the Area Graphical Application uses this class to draw a Rectangle in the UI
  • 16. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 16 Principles of OO Class Design SRP: The Single Responsibility Principle (cont) This violates SRP design principle as the Rectangle class has two responsibilities:  It calculates the value of the Rectangular area.  It renders the Rectangle in the UI. So, what is the problem?  We must include the GUI in the computational geometry application. While deployment of the geometry application, we must include GUI library. A change to the Rectangle class for Graphical application may lead to change, build and test the Computational geometry application.
  • 17. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 17 Principles of OO Class Design SRP: The Single Responsibility Principle (cont) A better design is to separate the two responsibilities into two completely different classes Why is it important to separate these two responsibilities into separate classes?
  • 18. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 18 Principles of OO Class Design SRP: The Single Responsibility Principle (cont) What is a Responsibility? “Responsibility” is defined as “a reason for change”. “Modem” sample  dial & hangup functions for managing connection  send & recv functions for data communication  Should separate into 2 repositories!
  • 19. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 19 Principles of OO Class Design OCP: The Open Closed Principle “Software entities(classes, modules, functions, etc.) should be open for extension, but closed for modification.” - Bertrand Meyer, 1988 Or “You should be able to extend a classes behavior, without modifying code” “Open for extension” This means that the behavior of the module/class can be extended and we can make the module behave in new and different ways as the requirements changes, or to meet the needs of new applications “Closed for Modification” The source code of such a module is inviolate. No one is allowed to make source code changes to it
  • 20. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 20 Principles of OO Class Design OCP: The Open Closed Principle (cont) Sample: Doesn’t support Open-Close Principle Client & Server classes are concrete. If the Server implementation/class is changed, Client also needs change.  How to resolve this problem?
  • 21. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 21 Principles of OO Class Design OCP: The Open Closed Principle (cont) Change to support Open-Closed Principle. Abstracion is the key. The Concrete Server class implements the Abstract Server class. The Server implementation is changed, the Client is likely not to require any change. The Abstract Server class here is closed for modification and the Concrete class implementations here are Open for extension.
  • 22. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 22 Principles of OO Class Design LSP: The Liskov Substitution Principle “Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.” Or “Subclasses should be substitutable for their base classes.”
  • 23. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 23 Principles of OO Class Design LSP: The Liskov Substitution Principle (cont) the KingFisher class extends the Bird base class and hence, inherits the Fly() method. Ostrich is also a Bird (Definitely it is!) and hence it inherits the Bird class. Now, can it fly? No! Here the design violates the LSP.  So, even if in real world this seems natural, in the class design, Ostrich should not inherit the Bird class and there should be a separate class for birds that can’t really fly and Ostrich should inherit that.
  • 24. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 24 Principles of OO Class Design LSP: The Liskov Substitution Principle (cont) In basic Object Oriented Principle, “Inheritance” is usually described as an "is a" relationship. Such “Is a” relationship is very important in class designs, but, its easy to get carried away and end up in wrong design with bad inheritance.  The “Liskov Substitution Principle” is a way of ensuring that inheritance is used correctly.
  • 25. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 25 Principles of OO Class Design LSP: The Liskov Substitution Principle (cont) Why The LSP is so important?  If LSP is not maintained, class hierarchies would be a mess and if subclass instance was passed as parameter to methods method, strange behavior might occur.  If LSP is not maintained, unit tests for the Base classes would never succeed for the subclass. LSP is just an extension of Open-Close Principle!!!
  • 26. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 26 Principles of OO Class Design ISP: The Interface Segregation Principle “Client should not be forced to depend upon interface that they do not use.” Or “Many client specific interfaces are better than one general purpose interface.”
  • 27. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 27 Principles of OO Class Design ISP: The Interface Segregation Principle (cont) Sample: Providing service for Client A,B,C {Applying ISP}
  • 28. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 28 Principles of OO Class Design ISP: The Interface Segregation Principle (cont) Interfaces with too many methods are less re-usable. Such "fat interfaces“ with additional useless methods lead to inadvertent coupling between classes. Doing this also introduce unnecessary complexity and reduces maintainability or robustness in the system. The ISP ensures that, Interfaces are developed so that, each of them have their own responsibility and thus they are re-usable.
  • 29. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 29 Principles of OO Class Design DIP: The Dependency Inversion Principle “High level modules should not depend upon low level modules. Both should depend upon abstractions” Or “Abstractions should not depend upon details. Details should depend upon abstraction.” Or “Depend upon Abstractions. Do not depend upon concretions.”
  • 30. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 30 Principles of OO Class Design DIP: The Dependency Inversion Principle (cont) The DIP is the strategy of depending upon interfaces or abstract functions and classes, rather than upon concrete functions and classes. The DIP describes the overall structure of a well designed object-oriented application. Sample: Layers of application
  • 31. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 31 6 Principles of Package Architecture 3 The Package Cohesion Principles REP: The Release/Reuse Equivalency Principle CRP: The Common Reuse Principle CCP: The Common Closure Principle 3 The Package Coupling Principles ADP: The Acyclic Dependencies Principle SDP: The Stable Dependencies Principle SAP: The Stable Abstractions Principle
  • 32. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 32 Why? When software application grows in size and complexity  they require some kind of high level organization. Applying for large application.
  • 33. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 33 Design with Packages Packages can be used as containers for a group of classes:  The design at a high level of abstraction. The relationships between those packages expresses the high level organization of the application Question for package design? What are the best grouping criteria? What are the relationships that exist between packages, and what design principles govern their use? Should packages be designed before classes (Top down)? Or should classes be designed before packages (Bottom up)? How are packages physically represented? Once created, to what purpose will we put these packages?
  • 34. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 34 The Package Cohesion Principles REP: The Release/Reuse Equivalency Principle “The granule of reuse is the granule of release. Only components that are released through a tracking system can be effectively reused. This granule is the package.” Or “The granule of reuse is the granule of release. Anything that it is reused must also be released”
  • 35. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 35 The Package Cohesion Principles REP: The Release/Reuse Equivalency Principle Packages are a candidate for a releasable entity. Packages might be possible to release and track classes (release version).
  • 36. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 36 The Package Cohesion Principles CRP: The Common Reuse Principle “The classes in a package are reused together. If you reuse one of the classes in a package, you reuse them all.” Or “Classes that are used together are packaged together.” Or “Classes that aren’t reused together should not be grouped together.”
  • 37. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 37 The Package Cohesion Principles CRP: The Common Reuse Principle A dependency upon a package is a dependency upon everything within the package. Which classes should be placed into a package? Generally reusable classes collaborate with other classes that are part of the reusable abstraction  These classes belong together in the same package.
  • 38. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 38 The Package Cohesion Principles CCP: The Common Closure Principle “The classes in a package should be closed together against the same kinds of changes. A change that affects a package affects all the classes in that package.” Or “Classes that change together are packaged together.”
  • 39. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 39 The Package Cohesion Principles CCP: The Common Closure Principle More important than reusability, is maintainability. What’s happen when application must change code?  changing at: all in one package, or distributed through many packages? All classes having the same changing reason must belong in the same package  This minimizes the workload related to releasing, revalidating, and redistributing the software.
  • 40. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 40 The Package Cohesion Principles Review The REP and CRP makes life easy for reuse. The CCP makes life easier for maintenance. The CCP strives to make packages as large as possible. The CRP tries to make packages very small.
  • 41. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 41 6 Principles of Package Architecture 3 The Package Cohesion Principles REP: The Release/Reuse Equivalency Principle CRP: The Common Reuse Principle CCP: The Common Closure Principle 3 The Package Coupling Principles ADP: The Acyclic Dependencies Principle SDP: The Stable Dependencies Principle SAP: The Stable Abstractions Principle
  • 42. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 42 The Package Cohesion Principles ADP: The Acyclic Dependencies Principle “The dependency structure between packages must be a directed acyclic graph (DAG). That is, there must be no cycles in the dependency structure.” Or “The dependencies between packages must not form cycles.”
  • 43. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 43 The Package Cohesion Principles ADP: The Acyclic Dependencies Principle Sample: Acyclic Package Network  What happen when releasing Protocol package? •Build with latest CommError package. •Run & Test Protocol package. Test & Release with minimal amount of work.
  • 44. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 44 The Package Cohesion Principles ADP: The Acyclic Dependencies Principle Sample: A Cycle Creeps In CommError can display error msg on GUI. What happen when Protocol package?  Build & Test everything!!!
  • 45. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 45 The Package Cohesion Principles ADP: The Acyclic Dependencies Principle Sample: Breaking Cycle There are 2 ways to break cycle: -Creating new package. -Make use of DIP and ISP. Both GUI & CommError packages depend upon one new package Message Manager
  • 46. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 46 The Package Cohesion Principles ADP: The Acyclic Dependencies Principle Sample: Breaking Cycle Using “BY” interface. There are 2 ways to break cycle: -Creating new package. -Make use of DIP and ISP.
  • 47. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 47 The Package Cohesion Principles SDP: The Stable Dependencies Principle “The dependencies between packages in a design should be the direction of the stability of the packages. A package should only depend upon packages that are more stable that it is” Or “Depend in the direction of stability.”
  • 48. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 48 The Package Cohesion Principles SDP: The Stable Dependencies Principle Stability is a measure of the difficulty in changing a module. The package is difficult to change because a lot of other packages depend upon it. A package with a lot of incoming dependencies is very stable because it requires a great deal of work to reconcile any changes with all the dependent packages. The package is more Stable  it is less Flexible.
  • 49. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 49 The Package Cohesion Principles SDP: The Stable Dependencies Principle Package X has 3 packages depending upon it.  X has 3 good reasons not to change!  X is responsible to those 3 packages. Package Y has no other packages depending upon it  Y is irresponsible. X is a stable package Y is a instable package
  • 50. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 50 The Package Cohesion Principles SDP: The Stable Dependencies Principle Stability Matrix: is used to calculate the possible stability of the package.  Ca : Afferent Couplings : The number of classes outside this package that depend upon classes within this package.  Ce : Efferent Couplings : The number of classes inside this package that depend upon classes outside this package.  I : Instability : (Ce ÷(Ca+Ce)) : This metric has the range [0,1] •I=0 indicates a maximally stable package. •I=1 indicates a maximally instable package.
  • 51. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 51 The Package Cohesion Principles SDP: The Stable Dependencies Principle Sample: Ca=4, Ce=3, and I=3/7
  • 52. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 52 The Package Cohesion Principles SDP: The Stable Dependencies Principle The I metric of a package should be larger than the I metrics of the packages that it depends upon. The I metrics should decrease in the direction of dependency. All the packages in a system were maximally stable (I=0), the system would be unchangeable.
  • 53. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 53 The Package Cohesion Principles SAP: The Stable Abstractions Principle “Packages that are maximally stable should be maximally abstract. Instable packages should be concrete. The abstraction of a package should be in proportion to its stability.” Or “Stable packages should be abstract packages.” Or “Abstractness increases with stability.”
  • 54. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 54 The Package Cohesion Principles SAP: The Stable Abstractions Principle A package is to be stable, it should also consist of abstract classes so that it can be extended. Stable packages that are extensible are flexible and do not constrain the design. The Abstractness Metrics:  Nc: Number of classes in package.  Na: Number of abstract classes in package.  A: Abstractness [0,1]. A= Na/Nc
  • 55. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 55 Sample: Package Diagram pkg Logical Architecture OverviewClient LayerPresentation LayerBusiness Logic LayerData Access LayerDatabase & External System LayerCommons LayerStruts 2.x(from Frameworks) webRichFace(from Frameworks) JSP(from Frameworks) SpringSecurity 3.x(from Frameworks) businesshibernate(from dao) email(from dao) ldap(from dao) Architecture Overview:: SMTP ServerArchitecture Overview:: Database schema Oracle 11gArchitecture Overview:: Group Directory SystemSpring Transation Manager 3.x(from Frameworks) Hibernate JPA 3.6.x(from Frameworks) schedulerSpringBatch 2.x(from Frameworks) Users(from Use Case View) modelSpring IoC 3.x(from Frameworks) utils«use» «forward» «use» «use» «use» «use» «access» «use» JDBC «access» LDAP «access» «use» «use» https«use» «dependency injection» SMTP/IMAP «access»
  • 56. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 56 Training Agenda •Introduce •Design Principles •Basic Design Patterns •Q&A
  • 57. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 57 What are Patterns? "Each pattern describes a problem which 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 A pattern is a general solution to a problem in a context • general -- outline of approach only • problem -- a recurring issue • context -- consider the expected design evolution
  • 58. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 58 What are Patterns About? Standard patterns of interactions between classes Design patterns How to apply them to your application Deal with subsystems at the higher level of abstraction provided by the patterns What to do when it does not fit exactly Evaluate options and analyze the trade-offs
  • 59. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 59 Why Patterns? Design for re-use is difficult Experienced designers: Rarely start from first principles Apply a working "handbook" of approaches Patterns make this ephemeral knowledge available to all. Support evaluation of alternatives at higher level of abstraction.
  • 60. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 60 Benefit from Design Pattern Design Patterns give you a shared vocabulary with other developers. Shared pattern vocabularies are POWERFUL. Patterns allow you to say more with less. Talking at the pattern level allows you to stay “in the design” longer. Shared vocabularies can turbo charge your development team. Shared vocabularies encourage more junior developers to get up to speed.
  • 61. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 61 How To Use Design Pattern?
  • 62. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 62 Basic Design Patterns The Strategy Pattern The Observer Pattern The Factory Pattern The Singleton Pattern
  • 63. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 63 The Strategy Pattern The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Sample Project: The game can show a large variety of duck species swimming and making quacking sounds. Using standard OO techniques (e.g: inheritance, interface, abstract classes…) Using Design Pattern.
  • 64. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 64 Using Standard OO Techniques
  • 65. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 65 Using Standard OO Techniques Needing fly for Duck???  Fail!!!
  • 66. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 66 Using Standard OO Techniques Using Interfaces  needing to override for every subclasses  Duplicated code!!!
  • 67. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 67 Using Design Pattern
  • 68. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 68 Using Design Pattern
  • 69. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 69 Using Design Pattern The key is that a Duck will now delegate its flying and quacking behavior, instead of using quacking and flying methods defined in the Duck class (or subclass).
  • 70. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 70 Using Design Pattern
  • 71. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 71 Using Design Pattern
  • 72. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 72 Design Pattern Toolbox OO Basic •Abstraction •Encapsulation •Polymorphism •Inheritance OO Principle •Encapsulate what varies. •Favor composition over inheritence. •Program to interfaces, not implementations. OO Pattern •Rely on OO basics and principles. •Strategy- defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
  • 73. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 73 Basic Design Patterns The Strategy Pattern The Observer Pattern The Factory Pattern The Singleton Pattern
  • 74. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 74 The Observer Pattern “ Keep your Objects in the know” This pattern keeps your objects in the know when something they might care about happens. Objects can even decide at runtime whether they want to be kept informed. Sample: Internet-based Weather Monitoring Station The weather station will be based on our patent pending WeatherData object, which tracks current weather conditions (temperature, humidity, and barometric pressure). The application is created to provides three display elements: current conditions, weather statistics and a simple forecast, all updated in real time.
  • 75. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 75 The Weather Monitoring App Overview
  • 76. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 76 The Weather Monitoring App Fist implementation
  • 77. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 77 The Weather Monitoring App What is wrong in this implementation?
  • 78. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 78 The Observer Pattern Idea Publishers + Subscribers = Observer Pattern The publisher the SUBJECT and the subscribers the OBSERVERS
  • 79. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 79 The Observer Pattern defined The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.
  • 80. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 80 An Observer Pattern Implementation
  • 81. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 81 Benefit of Observer Pattern??? The Observer Pattern provides an object design where subjects and observers are loosely coupled. The only thing the subject knows about an observer is that it implements a certain interface. We can add new observers at any time. We never need to modify the subject to add new types of observers. We can reuse subjects or observers independently of each other. Changes to either the subject or an observer will not affect the other.
  • 82. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 82 Designing the Weather Station a
  • 83. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 83 Implementing the Weather Station
  • 84. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 84 Implementing the Subject Interface
  • 85. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 85 Implementing the Observer Interface
  • 86. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 86 Design Pattern Toolbox OO Basic •Abstraction •Encapsulation •Polymorphism •Inheritance OO Principle •Encapsulate what varies. •Favor composition over inheritence. •Program to interfaces, not implementations. •Strive for loosely coupled designs between objects that interact OO Pattern •Rely on OO basics and principles. •Observer- defines a one- to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically
  • 87. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 87 Observer Pattern Highlight!!! The Observer Pattern defines a one-to-many relationship between objects. Subjects, or as we also know them, Observables, update Observers using a common interface. Observers are loosely coupled in that the Observable knows nothing about them, other than that they implement the Observer Interface. You can push or pull data from the Observable when using the pattern (pull is considered more “correct”). Don’t depend on a specific order of notification for your Observers.
  • 88. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 88 Design Principle Challenge Identify the aspects of your application that vary and separate them from what stays the same. Program to an interface, not an implementation. Favor composition over inheritance.
  • 89. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 89 Basic Design Patterns The Strategy Pattern The Observer Pattern The Factory Pattern The Singleton Pattern
  • 90. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 90 4. The Factory Pattern “Baking with OO Goodness” Get ready to bake some loosely coupled OO designs. There is more to making objects than just using the new operator. The ways to create objects Simple Factory/Static Factory Factory Method Pattern •Dependency Injection (DI) Abstract Factory Pattern When you see “new”, think “concrete”.
  • 91. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 91 Sample Code “Creation a Duck instance” What’s happen when updating or extending the code? Open the code and examine what needs to be added or deleted. This kind of code ends up is several parts of the application making maintenance and update more difficult and error –prone.
  • 92. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 92 Pizza Making Order “Support: CheesePizza, GreekPizza, PepperoniPizza”
  • 93. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 93 Pizza Making Order “What’s happen when adding more pizza type?” Messing up on orderPizza() method???
  • 94. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 94 Encapsulating Object Creation “Simple Factory/Static Factory”
  • 95. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 95 Pizza Making Order “With Simple Factory”
  • 96. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 96 The Simple Factory Defined The Simple Factory isn’t actually a Design Pattern; it’s more of a programming idiom.  But it is commonly used
  • 97. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 97 Extending for Pizza Store
  • 98. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 98 Factory Method Pattern The Factory Method Pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
  • 99. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 99 New Pizza Store “Applying Factory Method Pattern”
  • 100. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 100 New Pizza Store “Applying Factory Method Pattern”
  • 101. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 101 New Pizza Store “Applying Factory Method Pattern”
  • 102. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 102 The Dependency Inversion Principle Design Principle: Depend upon abstractions (interface, abstract, or super classes). Do not depend upon concrete classes. This principle is similar with “Program to an interface, not an implementation”.
  • 103. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 103 Abstract Factory Pattern The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.
  • 104. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 104 New PizzaStore... “Applying Abstract Factory Pattern” All Objectville’s Pizzas are made from the same components, but each region has a different implementation of those components.
  • 105. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 105 New PizzaStore... “Applying Abstract Factory Pattern”
  • 106. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 106 PizzaStore Class Diagram
  • 107. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 107 Factory Method & Abstract Factory Compared!!!
  • 108. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 108 Design Pattern Toolbox OO Basic •Abstraction •Encapsulation •Polymorphism •Inheritance OO Principle •Encapsulate what varies. •Favor composition over inheritence. •Program to interfaces, not implementations. •Depend on abstractions. Do not depend on concrete classes. OO Pattern •Rely on OO basics and principles. •Factory Method- Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to the subclasses. •Abstract Factory- Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
  • 109. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 109 Factory Pattern Highlight!!! All factories encapsulate object creation. Simple Factory, while not a bona fide design pattern, is a simple way to decouple your clients from concrete classes. Factory Method relies on inheritance: object creation is delegated to subclasses which implement the factory method to create objects. Abstract Factory relies on object composition: object creation is implemented in methods exposed in the factory interface. All factory patterns promote loose coupling by reducing the dependency of your application on concrete classes. The intent of Factory Method is to allow a class to defer instantiation to its subclasses. The intent of Abstract Factory is to create families of related objects without having to depend on their concrete classes. The Dependency Inversion Principle guides us to avoid dependencies on concrete types and to strive for abstractions. Factories are a powerful technique for coding to abstractions, not concrete classes
  • 110. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 110 Basic Design Patterns The Strategy Pattern The Observer Pattern The Factory Pattern The Singleton Pattern
  • 111. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 111 5. The Singleton Pattern “One of a Kind Objects” There is ONE and ONLY ONE object/instance to serve all requests. There are many objects, the program will run into all sorts of problems like incorrect behavior, overuse of resource, or inconsistent results (e.g: Thread Pools, Caches, Dialog Boxes, Object that handle preferences and registry setting, objects used for logging,…)
  • 112. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 112 The Singleton Pattern “A Implementation”
  • 113. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 113 Singleton Pattern Defined The Singleton Pattern ensures a class has only one instance, and provides a global point of access to it. The class will manage a single instance of itself. The class prevents any other class from creating a new instance on its own. The class provides a global access point to the instance.
  • 114. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 114 Dealing with Multithreading Using synchronized keyword to avoid dead lock in multi-threading.
  • 115. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 115 Design Pattern Toolbox OO Basic •Abstraction •Encapsulation •Polymorphism •Inheritance OO Principle •Encapsulate what varies. •Favor composition over inheritence. •Program to interfaces, not implementations. OO Pattern •Rely on OO basics and principles. •Singleton- Ensure a one instance and provide a global point of access to it.
  • 116. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 116 Singleton Pattern Highlight!!! The Singleton Pattern ensures you have at most one instance of a class in the application. The Singleton Pattern also provides a global access point to that instance. Java’s implementation of the Singleton Pattern makes use of a private constructor, a static method combined with a static variable. Examine your performance and resource constraints and carefully choose an appropriate Singleton implementation for multithreaded applications (and you should consider all applications multithreaded!). Beware of the double-checked locking implementation. Be careful if you are using multiple class loaders; this could defeat the Singleton implementation and result in multiple instances.
  • 117. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 117 Sample: Voice Control Wrapper The system uses third party for voice control module. We plan to user other third party voice control in the future, so needing to design a wrapper package to avoid impaction when changing. How to do this ones?
  • 118. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 118 Sample: Voice Control Wrapper Package Diagram
  • 119. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 119 Sample: Voice Control Wrapper Classes Diagram
  • 120. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 120 Basic Design Pattern Book
  • 121. © FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/4 121 Q & A