SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
Agile Software Development
By- Md. Mojammel Haque
CSM, CSPO, CSD, CSP (Scrum Alliance)
Software Architect- Raven Systems Ltd.
mojamcpds@gmail.com
http://codermojam.com
Cell- 01795-231350
Agile Principles
• Satisfy Customer by through early and
contentious delivery of Valuable Software
• Welcome changing requirements even late in
Development
• Deliver working Software frequently from a
couple of weeks to couple of months
• Business People & Developers must work
together daily
Agile Principles
• Build projects around motivated individuals
who should be trusted
• Face to face communication is the best form
of Conversation even in co-location
• Working software is the principal measure of
progress
• Sustainable development, able to maintain a
constant pace
Agile Principles
• Continuous attention to technical excellence
and good design
• Simplicity—the art of maximizing the amount
of work not done—is essential
• Self-organizing teams
• Regular adaptation to changing circumstance
Agile Software Fundamentals
• Principles
• Patterns
• Practices
Simplify Client Access to complex functionality- Façade
Spaghetti Code
Problem with Above Code
• Violation of Single Responsibility Principle
– Establish & Open Connection
– Loading Data Table
– Taking the Result & Mapping with Domain Object
• Violation of Don’t Repeat Yourself Principle
– Each time we create new method lot of stuff need
to repeat e.g.- Define Connection, Provide
Connection String, Open Connection, Create
Command etc.
Refactoring To Pattern- Factory
• Only use to establish the connection with Database- SRP
• Can reuse this code in whole project- DRY
• Create As much instance as required- Factory Pattern
Use Factory pattern to Façade
Is our code Refactored enough?
Yes! - “Our Code is not tightly coupled with any
specific connection. Instead it relies on
Abstraction i.e. IDbConnection.”
If user wants to use “Oracle” or any other
database instead of “SQL Server”?
“Create another Connection Factory for that
database.”
OracleDbProviderFactory
Call from Façade
Problem with Above Code
• Violate the rule of Abstract Factory Pattern-
“User will not be aware about what is being
created and how is being created.”
• Each time we call-
– Either SQLServerDbProviderFactory
– Or OracleDbProviderFactory
Our user knows it- which one is calling
Abstract Factory?
In our Connection code we have two level of Abstraction-
+. IDbConnection : Create the factory of SQL Connection or
Oracle Connection
+. IDbProviderFactory: Create the instance of SQL Provider or
Oracle Provider Factory.
So, we have abstraction on Factory– Abstract Factory.
Refactor to Next Level
+. Get the Provider Name from Configuration file no matter weather
it is SQL client or Oracle client. All other code are same. So we don’t
need to create individual factory class for each database provider
Consume the code from Façade
+. Created the instance of ProviderFactory and used it to
CreateConnection. So end user doesn’t know about which provider
we are being using.
But…. Problem Here
+. Each time we call EmployeeService it creates
an instance of DbProviderFactory class which is
wastage.
+. So we have to Avoid this Wastage.
Introducing Singleton instance of Factory
Create the Singleton Instance of DbProviderFactory class.
So only one instance of DbProviderFactory will use instead
of creating multiple instances.
Note: We are not using one connection for the application. We
are actually using one factory for each application
Call from Façade – Dependency Injection
• In Above Code we are used Dependency Injection Pattern
by injecting IDbProviderFactory through the Constructor of
EmployeeService Class.
• Though we are not using any Ioc container here so we
handled the dependency in Poor man Style
There are some problem of using Singleton in above style
– Our above Singleton is not Thread Safe
– Also the Singleton instance is Immutable
So we have to Refactor our above code-
Refactor to Monostate Pattern
• In Monostate Pattern we have Private Static instance of DbProviderFactory
instead of Public Static instance. We also have a static Constructor.
• The only difference between Monostate and Singleton is in Monostate client
doesn’t realize that they are working with a Single Intance
Refactor to Monostate Pattern
• In Monostate Pattern we have Private Static instance of
DbProviderFactory instead of Public Static instance. We also have a
static Constructor.
• Monostate Design Pattern allows us to create instance as much as
required. But though DbProviderFactory instance static so it get
initialized only once.
• The Difference between Singleton and Monostate is
– The Singleton is the single instance
– Monostate has multiple instance but internal instance is limited to only
one.
• In Monostate client doesn’t realize that they are working with a
Single Instance.
• In MonostateProviderFactory all methods are mutable. So they will
return completely brand new instance to the client and they can be
used very safely in Multi-Threaded environment.
Strategy Design Pattern
• Clients needs-
– Employee list needs to shown in sorted by their birth date
So we write our code for this client requirement-
Our Unit Test code is
Wow! Our unit test passed and our code works properly-
Strategy Design Pattern- Contd.
After few days Client has another requirements which is-
“In another place Employee List should be seen sorted by their First Name”
Now what will we do?
– Create another method for Sorting by their First Name.
– Or introduce a if condition for sorting by First Name
Strategy Design Pattern- Contd.
Few days later user has another requirement to show
“Employee List by sorting their Last Name”
We have to follow one of above two processes i.e. -
– So Create another method for Sorting by their Last Name.
– Or introduce a if condition for sorting by Last Name
+. As day by day client requirements increases and our code also increases. So
after few days our class will become bulky and completely loss it’s
maintainability.
+. Also it violates the rules of –
1. Open Closed Principle (OCP):
+>. Either modify our class (introducing a brand new method
for each logic i.e. SortByDate, SortByName etc.)
+>. Or modify existing method by adding new condition e.g.-
condition for sortByDate, sortByName etc.
2. Don’t Repeat Yourself (DRY) : Same logic repeat again and again
Refactoring to Strategy Pattern
Now create a class that will Compare two employee objects
by their birth date and consume it from client-
Refactoring to Strategy Pattern
Now for First Name sorting we will create another class
For Last Name Sorting we will follow the same process i.e.
create another class
Refactoring to Strategy Pattern
No modification will require for our Sorting method. Also don’t need to
introduce new method for each sorting logic-
Our end user will just consume the method by passing individual
Icomparer<Iemployee> as parameter value and return the output
according to sorting logic as follows-
Same above process should follows for sortByName
+. This pattern is known as “Strategy Pattern” because it interchanges the
Compare method of different class based on client need.
+. This is also known as Replace Conditionals with Polymorphism (RCP/RIP)
pattern because instead of using if conditions we just used polymorphism logic to
override the compare method in different classes.
Gateway Design Pattern
 Till now we write all database access logic into Service Layer.
 If we have multiple service class then we have to write all the
database access logic all those Service classes.
 It’s not any good practice. The good practices is-
“We’ll create a single access point to database so that all service
layer components can access database by using that access point.”
Refactor to Gateway Design Pattern
This access point is our Gateway
Now our Service Layer will contact with database via Gateway.
Refactor to Gateway Design Pattern
Source code of our access point-
Refactor to Gateway Design Pattern
Access Gateway from Service Layer
Repository & Unit Of Work Design Pattern
According to Eric Evans-
“A repository will connect Factories with Gateways.”
[“Factory is the convenient way to create objects”]
+. Here Factory means instance of Domain Model
+. Gateway is the access point that we discussed earlier
So we will introduce Repository pattern as the connector
between Domain Model and Gateway via Service Layer.
Repository & Unit Of Work Design Pattern
Repository & Unit Of Work Design Pattern
Unit of Work uses to Commit or Rollback one or more
operations as a Single Transaction.
Repository & Unit Of Work Design Pattern
Use Repository and & Unit of work in Service Layer-
Repository & Unit Of Work Design Pattern
Use Repository and & Unit of work in Service Layer-
Test Read Statement
Test Single Save Statement
Test Multiple Save Statement- Failed Case
Test Multiple Save Statement- Passed Case

Contenu connexe

Tendances

2010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week12010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week1Wolfram Arnold
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJSTroy Miles
 
Styled Components & React.js
Styled Components & React.jsStyled Components & React.js
Styled Components & React.jsGrayson Hicks
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails AppsRabble .
 
Subconsultas
SubconsultasSubconsultas
SubconsultasMaria
 
Styled components presentation
Styled components presentationStyled components presentation
Styled components presentationMaciej Matuszewski
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with CucumberAsheesh Mehdiratta
 
Intro to Service Worker API and its use cases
Intro to Service Worker API and its use casesIntro to Service Worker API and its use cases
Intro to Service Worker API and its use casessatejsahu
 
Improve your development skills with Test Driven Development
Improve your development skills with Test Driven DevelopmentImprove your development skills with Test Driven Development
Improve your development skills with Test Driven DevelopmentJohn Stevenson
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Knoldus Inc.
 
Clean code quotes - Citações e provocações
Clean code quotes - Citações e provocaçõesClean code quotes - Citações e provocações
Clean code quotes - Citações e provocaçõesAndré de Fontana Ignacio
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD WorkshopWolfram Arnold
 
Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomasintuit_india
 
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 IndiaUsing the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 IndiaArun Gupta
 
Micro Object Testing
Micro Object TestingMicro Object Testing
Micro Object TestingESUG
 

Tendances (20)

2010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week12010-07-19_rails_tdd_week1
2010-07-19_rails_tdd_week1
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
 
UI Testing
UI TestingUI Testing
UI Testing
 
Refactoring
RefactoringRefactoring
Refactoring
 
Styled Components & React.js
Styled Components & React.jsStyled Components & React.js
Styled Components & React.js
 
Testing Legacy Rails Apps
Testing Legacy Rails AppsTesting Legacy Rails Apps
Testing Legacy Rails Apps
 
Subconsultas
SubconsultasSubconsultas
Subconsultas
 
Styled components presentation
Styled components presentationStyled components presentation
Styled components presentation
 
Gemboys
GemboysGemboys
Gemboys
 
Behavior Driven Development with Cucumber
Behavior Driven Development with CucumberBehavior Driven Development with Cucumber
Behavior Driven Development with Cucumber
 
Intro to Service Worker API and its use cases
Intro to Service Worker API and its use casesIntro to Service Worker API and its use cases
Intro to Service Worker API and its use cases
 
Improve your development skills with Test Driven Development
Improve your development skills with Test Driven DevelopmentImprove your development skills with Test Driven Development
Improve your development skills with Test Driven Development
 
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
Play framework training by Neelkanth Sachdeva @ Scala traits event , New Delh...
 
Clean code quotes - Citações e provocações
Clean code quotes - Citações e provocaçõesClean code quotes - Citações e provocações
Clean code quotes - Citações e provocações
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop
 
Karate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter ThomasKarate for Complex Web-Service API Testing by Peter Thomas
Karate for Complex Web-Service API Testing by Peter Thomas
 
Jasmine
JasmineJasmine
Jasmine
 
Cucumber_Training_ForQA
Cucumber_Training_ForQACucumber_Training_ForQA
Cucumber_Training_ForQA
 
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 IndiaUsing the latest Java Persistence API 2 Features - Tech Days 2010 India
Using the latest Java Persistence API 2 Features - Tech Days 2010 India
 
Micro Object Testing
Micro Object TestingMicro Object Testing
Micro Object Testing
 

Similaire à Commonly used design patterns

Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2divzi1913
 
Angular Ivy- An Overview
Angular Ivy- An OverviewAngular Ivy- An Overview
Angular Ivy- An OverviewJalpesh Vadgama
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - TalkMatthias Noback
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with BlackfireMarko Mitranić
 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2Smita B Kumar
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principlesdeonpmeyer
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2Long Nguyen
 
Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014Lars-Erik Kindblad
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxdanhaley45372
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts weili_at_slideshare
 
CMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORTCMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORTSandyarathi Das
 
Alfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring MvcAlfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring MvcDaniel Gradecak
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf
 

Similaire à Commonly used design patterns (20)

Design p atterns
Design p atternsDesign p atterns
Design p atterns
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Angular Ivy- An Overview
Angular Ivy- An OverviewAngular Ivy- An Overview
Angular Ivy- An Overview
 
L06 Using Design Patterns
L06 Using Design PatternsL06 Using Design Patterns
L06 Using Design Patterns
 
Advanced web application architecture - Talk
Advanced web application architecture - TalkAdvanced web application architecture - Talk
Advanced web application architecture - Talk
 
Grails Services
Grails ServicesGrails Services
Grails Services
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test Automation
 
2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire2019 StartIT - Boosting your performance with Blackfire
2019 StartIT - Boosting your performance with Blackfire
 
01 introduction to struts2
01 introduction to struts201 introduction to struts2
01 introduction to struts2
 
Object Oriented Concepts and Principles
Object Oriented Concepts and PrinciplesObject Oriented Concepts and Principles
Object Oriented Concepts and Principles
 
Struts 2-overview2
Struts 2-overview2Struts 2-overview2
Struts 2-overview2
 
Application Architecture April 2014
Application Architecture April 2014Application Architecture April 2014
Application Architecture April 2014
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts Build Java Web Application Using Apache Struts
Build Java Web Application Using Apache Struts
 
Clean architecture
Clean architectureClean architecture
Clean architecture
 
CMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORTCMPE282_009994036_PROJECT_REPORT
CMPE282_009994036_PROJECT_REPORT
 
Application Architecture
Application ArchitectureApplication Architecture
Application Architecture
 
Mvc
MvcMvc
Mvc
 
Alfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring MvcAlfresco Mvc - a seamless integration with Spring Mvc
Alfresco Mvc - a seamless integration with Spring Mvc
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 

Plus de Mojammel Haque

Agile Estimating and Planning
Agile Estimating and PlanningAgile Estimating and Planning
Agile Estimating and PlanningMojammel Haque
 
Agile Estimating And Planning
Agile Estimating And PlanningAgile Estimating And Planning
Agile Estimating And PlanningMojammel Haque
 
Real Time App with SignalR
Real Time App with SignalRReal Time App with SignalR
Real Time App with SignalRMojammel Haque
 
Real time app with SignalR
Real time app with SignalR Real time app with SignalR
Real time app with SignalR Mojammel Haque
 

Plus de Mojammel Haque (6)

Introduction to scrum
Introduction to scrumIntroduction to scrum
Introduction to scrum
 
Agile Estimating and Planning
Agile Estimating and PlanningAgile Estimating and Planning
Agile Estimating and Planning
 
Agile Estimating And Planning
Agile Estimating And PlanningAgile Estimating And Planning
Agile Estimating And Planning
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Real Time App with SignalR
Real Time App with SignalRReal Time App with SignalR
Real Time App with SignalR
 
Real time app with SignalR
Real time app with SignalR Real time app with SignalR
Real time app with SignalR
 

Dernier

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 

Dernier (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 

Commonly used design patterns

  • 1. Agile Software Development By- Md. Mojammel Haque CSM, CSPO, CSD, CSP (Scrum Alliance) Software Architect- Raven Systems Ltd. mojamcpds@gmail.com http://codermojam.com Cell- 01795-231350
  • 2.
  • 3. Agile Principles • Satisfy Customer by through early and contentious delivery of Valuable Software • Welcome changing requirements even late in Development • Deliver working Software frequently from a couple of weeks to couple of months • Business People & Developers must work together daily
  • 4. Agile Principles • Build projects around motivated individuals who should be trusted • Face to face communication is the best form of Conversation even in co-location • Working software is the principal measure of progress • Sustainable development, able to maintain a constant pace
  • 5. Agile Principles • Continuous attention to technical excellence and good design • Simplicity—the art of maximizing the amount of work not done—is essential • Self-organizing teams • Regular adaptation to changing circumstance
  • 6. Agile Software Fundamentals • Principles • Patterns • Practices
  • 7. Simplify Client Access to complex functionality- Façade Spaghetti Code
  • 8. Problem with Above Code • Violation of Single Responsibility Principle – Establish & Open Connection – Loading Data Table – Taking the Result & Mapping with Domain Object • Violation of Don’t Repeat Yourself Principle – Each time we create new method lot of stuff need to repeat e.g.- Define Connection, Provide Connection String, Open Connection, Create Command etc.
  • 9. Refactoring To Pattern- Factory • Only use to establish the connection with Database- SRP • Can reuse this code in whole project- DRY • Create As much instance as required- Factory Pattern
  • 10. Use Factory pattern to Façade
  • 11. Is our code Refactored enough? Yes! - “Our Code is not tightly coupled with any specific connection. Instead it relies on Abstraction i.e. IDbConnection.” If user wants to use “Oracle” or any other database instead of “SQL Server”? “Create another Connection Factory for that database.”
  • 14. Problem with Above Code • Violate the rule of Abstract Factory Pattern- “User will not be aware about what is being created and how is being created.” • Each time we call- – Either SQLServerDbProviderFactory – Or OracleDbProviderFactory Our user knows it- which one is calling
  • 15. Abstract Factory? In our Connection code we have two level of Abstraction- +. IDbConnection : Create the factory of SQL Connection or Oracle Connection +. IDbProviderFactory: Create the instance of SQL Provider or Oracle Provider Factory. So, we have abstraction on Factory– Abstract Factory.
  • 16. Refactor to Next Level +. Get the Provider Name from Configuration file no matter weather it is SQL client or Oracle client. All other code are same. So we don’t need to create individual factory class for each database provider
  • 17. Consume the code from Façade +. Created the instance of ProviderFactory and used it to CreateConnection. So end user doesn’t know about which provider we are being using.
  • 18. But…. Problem Here +. Each time we call EmployeeService it creates an instance of DbProviderFactory class which is wastage. +. So we have to Avoid this Wastage.
  • 19. Introducing Singleton instance of Factory Create the Singleton Instance of DbProviderFactory class. So only one instance of DbProviderFactory will use instead of creating multiple instances. Note: We are not using one connection for the application. We are actually using one factory for each application
  • 20. Call from Façade – Dependency Injection
  • 21. • In Above Code we are used Dependency Injection Pattern by injecting IDbProviderFactory through the Constructor of EmployeeService Class. • Though we are not using any Ioc container here so we handled the dependency in Poor man Style There are some problem of using Singleton in above style – Our above Singleton is not Thread Safe – Also the Singleton instance is Immutable So we have to Refactor our above code-
  • 22. Refactor to Monostate Pattern • In Monostate Pattern we have Private Static instance of DbProviderFactory instead of Public Static instance. We also have a static Constructor. • The only difference between Monostate and Singleton is in Monostate client doesn’t realize that they are working with a Single Intance
  • 23. Refactor to Monostate Pattern • In Monostate Pattern we have Private Static instance of DbProviderFactory instead of Public Static instance. We also have a static Constructor. • Monostate Design Pattern allows us to create instance as much as required. But though DbProviderFactory instance static so it get initialized only once. • The Difference between Singleton and Monostate is – The Singleton is the single instance – Monostate has multiple instance but internal instance is limited to only one. • In Monostate client doesn’t realize that they are working with a Single Instance. • In MonostateProviderFactory all methods are mutable. So they will return completely brand new instance to the client and they can be used very safely in Multi-Threaded environment.
  • 24. Strategy Design Pattern • Clients needs- – Employee list needs to shown in sorted by their birth date So we write our code for this client requirement- Our Unit Test code is Wow! Our unit test passed and our code works properly-
  • 25. Strategy Design Pattern- Contd. After few days Client has another requirements which is- “In another place Employee List should be seen sorted by their First Name” Now what will we do? – Create another method for Sorting by their First Name. – Or introduce a if condition for sorting by First Name
  • 26. Strategy Design Pattern- Contd. Few days later user has another requirement to show “Employee List by sorting their Last Name” We have to follow one of above two processes i.e. - – So Create another method for Sorting by their Last Name. – Or introduce a if condition for sorting by Last Name +. As day by day client requirements increases and our code also increases. So after few days our class will become bulky and completely loss it’s maintainability. +. Also it violates the rules of – 1. Open Closed Principle (OCP): +>. Either modify our class (introducing a brand new method for each logic i.e. SortByDate, SortByName etc.) +>. Or modify existing method by adding new condition e.g.- condition for sortByDate, sortByName etc. 2. Don’t Repeat Yourself (DRY) : Same logic repeat again and again
  • 27. Refactoring to Strategy Pattern Now create a class that will Compare two employee objects by their birth date and consume it from client-
  • 28. Refactoring to Strategy Pattern Now for First Name sorting we will create another class For Last Name Sorting we will follow the same process i.e. create another class
  • 29. Refactoring to Strategy Pattern No modification will require for our Sorting method. Also don’t need to introduce new method for each sorting logic- Our end user will just consume the method by passing individual Icomparer<Iemployee> as parameter value and return the output according to sorting logic as follows- Same above process should follows for sortByName +. This pattern is known as “Strategy Pattern” because it interchanges the Compare method of different class based on client need. +. This is also known as Replace Conditionals with Polymorphism (RCP/RIP) pattern because instead of using if conditions we just used polymorphism logic to override the compare method in different classes.
  • 30. Gateway Design Pattern  Till now we write all database access logic into Service Layer.  If we have multiple service class then we have to write all the database access logic all those Service classes.  It’s not any good practice. The good practices is- “We’ll create a single access point to database so that all service layer components can access database by using that access point.”
  • 31. Refactor to Gateway Design Pattern This access point is our Gateway Now our Service Layer will contact with database via Gateway.
  • 32. Refactor to Gateway Design Pattern Source code of our access point-
  • 33. Refactor to Gateway Design Pattern Access Gateway from Service Layer
  • 34. Repository & Unit Of Work Design Pattern According to Eric Evans- “A repository will connect Factories with Gateways.” [“Factory is the convenient way to create objects”] +. Here Factory means instance of Domain Model +. Gateway is the access point that we discussed earlier So we will introduce Repository pattern as the connector between Domain Model and Gateway via Service Layer.
  • 35. Repository & Unit Of Work Design Pattern
  • 36. Repository & Unit Of Work Design Pattern Unit of Work uses to Commit or Rollback one or more operations as a Single Transaction.
  • 37. Repository & Unit Of Work Design Pattern Use Repository and & Unit of work in Service Layer-
  • 38. Repository & Unit Of Work Design Pattern Use Repository and & Unit of work in Service Layer-
  • 40. Test Single Save Statement
  • 41. Test Multiple Save Statement- Failed Case
  • 42. Test Multiple Save Statement- Passed Case