SlideShare a Scribd company logo
1 of 40
Use Design Principle to Improve code quality
Hebin Wei
Agenda
Agile needs good design
What is a good design
How the Design Principles help improve code quality.
Doing the right thing vs Doing the thing right
Doing the right things
Move
Change
Direction
Needs a
seat
Look cool
Doing the thing right
An example – let’s change active policy title
to blue
if (policy.policyStatusCode === 'A')
{
// policy is active,
// display policy title in green
}
if (policy.policyStatus === 'Active')
{
// policy id active
// display policy title in green
}
As a new developer how easy would it be to find this code
and change the title to blue?
Agile breaks down each problem into smaller pieces,
which makes it hard to see the big picture.
Smaller problems can solved with quick solutions,
but the quick solutions end up staying.
Agile still needs good software design
What is good software design?
“The foundation of good software design is
separation of concerns”
https://www.intertech.com/Blog/principles-of-good-software-design/
Good software design
Modularized
Understandable
Reusable
Extensible
Testable
As a developer, your code:
● Must work
● Needs to embrace changes
● Is production support friendly
● Should cover all known scenarios / bugs with automated tests
● Is not overkill
How can we have good design without being able
to see the big picture?
Design Principles
Object Oriented Design
Is Object Oriented dead?
OOD != OOP
OOD != Class
SOLID Principles
Single responsibility
Each module should only have one responsibility
That responsibility should only be handled by one
module
Size of responsibility depends on the scope
Open / Closed
Open for extension
● Subclass
● Composition
● Dependency Injection
Closed for modification
● Private scope by default
● Using accessors if possible
export const privateFunction = (policyType
= '') => {
let result = policyType;
...
return result;
};
export const publicFunction =(policy) =>{
const someVariable =
privateFunction(policy.policyType);
...
return someValue;
};
export default publicFunction;
Liskov substitution
https://lassala.net/2010/11/04/a-good-example-of-liskov-substitution-principle/
Interface segregation
https://lassala.net/2010/11/04/a-good-example-of-liskov-substitution-principle/
Thinking in
Interfaces!
Dependency inversion
How the SOLID principles help create a good design
Objective VS Subjective
VS
Prepared for changes
Open / Closed
Interface segregation
Liskov substitution
Dependency inversion
Prepared for changes --OCP
Prepared for changes -- ISP
Prepared for changes - DIP
● ReactWindow implements IWindow
● AngularWindow implements IWindow
● AndriodWindow implements IWindow
● DojoWindow implements IWindow
Understandable
Single responsibility
Interface segregation
Dependency inversion
Understandable - SRP
Understandable -- ISP
Understandable -- DIP
Testable
Single responsibility
Interface segregation
Dependency inversion
Q&A

More Related Content

What's hot

Specification by Example - Agile India 2015
Specification by Example - Agile India 2015Specification by Example - Agile India 2015
Specification by Example - Agile India 2015Ankur Sambhar
 
Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...
Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...
Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...Lviv Startup Club
 
Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013   corneliu rimboiu - bridging java and .netIasi code camp 12 october 2013   corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .netCodecamp Romania
 
BDD on Java Concordion and Selenium
BDD on Java Concordion and SeleniumBDD on Java Concordion and Selenium
BDD on Java Concordion and Seleniumspringbyexample
 
Understand the background of Agile software development now
Understand the background of Agile software development nowUnderstand the background of Agile software development now
Understand the background of Agile software development nowNirajan Panthee
 
Specification by example - course summary
Specification by example - course summarySpecification by example - course summary
Specification by example - course summaryJakub Holy
 
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013TEST Huddle
 
#T3SCRUM: 12 principles of agile
#T3SCRUM: 12 principles of agile#T3SCRUM: 12 principles of agile
#T3SCRUM: 12 principles of agileak-itconsulting.com
 
Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Sakares Saengkaew
 
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It IsAmanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It IsRehgan Avon
 
Retrofitting a legacy SPA to use a functional architecture
Retrofitting a legacy SPA to use a functional architectureRetrofitting a legacy SPA to use a functional architecture
Retrofitting a legacy SPA to use a functional architectureManuel Rivero
 
How different Minimum Viable Products helped us understand customers.
How different Minimum Viable Products helped us understand customers.How different Minimum Viable Products helped us understand customers.
How different Minimum Viable Products helped us understand customers.Pushkar Gaikwad
 
An overview of agile practices
An overview of agile practicesAn overview of agile practices
An overview of agile practicesDr. Padmavathi Roy
 
Kaggle Vs Real-world Projects
Kaggle Vs Real-world ProjectsKaggle Vs Real-world Projects
Kaggle Vs Real-world ProjectsAnkit Rathi
 

What's hot (19)

Agile Manifesto
Agile ManifestoAgile Manifesto
Agile Manifesto
 
Design pattern in js
Design pattern in jsDesign pattern in js
Design pattern in js
 
Specification by Example - Agile India 2015
Specification by Example - Agile India 2015Specification by Example - Agile India 2015
Specification by Example - Agile India 2015
 
Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...
Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...
Андрій Просов: Managing Client Expectations in Fixed Price Agile Projects by ...
 
Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013   corneliu rimboiu - bridging java and .netIasi code camp 12 october 2013   corneliu rimboiu - bridging java and .net
Iasi code camp 12 october 2013 corneliu rimboiu - bridging java and .net
 
BDD on Java Concordion and Selenium
BDD on Java Concordion and SeleniumBDD on Java Concordion and Selenium
BDD on Java Concordion and Selenium
 
Understand the background of Agile software development now
Understand the background of Agile software development nowUnderstand the background of Agile software development now
Understand the background of Agile software development now
 
Specification by example - course summary
Specification by example - course summarySpecification by example - course summary
Specification by example - course summary
 
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
Emily Bache - Readable, Executable Requirements: Hands-On - EuroSTAR 2013
 
#T3SCRUM: 12 principles of agile
#T3SCRUM: 12 principles of agile#T3SCRUM: 12 principles of agile
#T3SCRUM: 12 principles of agile
 
Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd Practiced agile developer with tdd & bdd
Practiced agile developer with tdd & bdd
 
Agile Development Models
Agile Development ModelsAgile Development Models
Agile Development Models
 
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It IsAmanda Cinnamon - Treat Your Code Like the Valuable Software It Is
Amanda Cinnamon - Treat Your Code Like the Valuable Software It Is
 
Retrofitting a legacy SPA to use a functional architecture
Retrofitting a legacy SPA to use a functional architectureRetrofitting a legacy SPA to use a functional architecture
Retrofitting a legacy SPA to use a functional architecture
 
Agile introduction
Agile introductionAgile introduction
Agile introduction
 
How different Minimum Viable Products helped us understand customers.
How different Minimum Viable Products helped us understand customers.How different Minimum Viable Products helped us understand customers.
How different Minimum Viable Products helped us understand customers.
 
Ooad presentation
Ooad presentationOoad presentation
Ooad presentation
 
An overview of agile practices
An overview of agile practicesAn overview of agile practices
An overview of agile practices
 
Kaggle Vs Real-world Projects
Kaggle Vs Real-world ProjectsKaggle Vs Real-world Projects
Kaggle Vs Real-world Projects
 

Similar to Use Design Principles to Improve Code Quality

Always Be Deploying. How to make R great for machine learning in (not only) E...
Always Be Deploying. How to make R great for machine learning in (not only) E...Always Be Deploying. How to make R great for machine learning in (not only) E...
Always Be Deploying. How to make R great for machine learning in (not only) E...Wit Jakuczun
 
Best practices for agile design
Best practices for agile designBest practices for agile design
Best practices for agile designIgor Moochnick
 
Tetap Agile dengan Arsitektur Monolith - Ziya El Arief
Tetap Agile dengan Arsitektur Monolith - Ziya El AriefTetap Agile dengan Arsitektur Monolith - Ziya El Arief
Tetap Agile dengan Arsitektur Monolith - Ziya El AriefDicodingEvent
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionKnoldus Inc.
 
Agile Software Architecture
Agile Software ArchitectureAgile Software Architecture
Agile Software Architecturecesarioramos
 
He mian agile project-inception
He mian   agile project-inceptionHe mian   agile project-inception
He mian agile project-inceptionOdd-e
 
The Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary VersionThe Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary VersionPhilip Schwarz
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo designConfiz
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia eventXebia India
 
1. oop with c++ get 410 day 1
1. oop with c++ get 410   day 11. oop with c++ get 410   day 1
1. oop with c++ get 410 day 1Mukul kumar Neal
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_pptagnes_crepet
 
Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Adi Bolboaca
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introductionwojtek_s
 
Practical Enterprise Application Development
Practical Enterprise Application DevelopmentPractical Enterprise Application Development
Practical Enterprise Application DevelopmentAdil Mughal
 
Model Driven Architectures
Model Driven ArchitecturesModel Driven Architectures
Model Driven ArchitecturesLalit Kale
 
Agile & Secure SDLC
Agile & Secure SDLCAgile & Secure SDLC
Agile & Secure SDLCPaul Yang
 
Architecting Solutions and Systems – Randy’s Secrets to Success
Architecting Solutions and Systems – Randy’s Secrets to SuccessArchitecting Solutions and Systems – Randy’s Secrets to Success
Architecting Solutions and Systems – Randy’s Secrets to SuccessRandy Williams
 
Interview preparation net_asp_csharp
Interview preparation net_asp_csharpInterview preparation net_asp_csharp
Interview preparation net_asp_csharpMallikarjuna G D
 

Similar to Use Design Principles to Improve Code Quality (20)

Always Be Deploying. How to make R great for machine learning in (not only) E...
Always Be Deploying. How to make R great for machine learning in (not only) E...Always Be Deploying. How to make R great for machine learning in (not only) E...
Always Be Deploying. How to make R great for machine learning in (not only) E...
 
Best practices for agile design
Best practices for agile designBest practices for agile design
Best practices for agile design
 
Tetap Agile dengan Arsitektur Monolith - Ziya El Arief
Tetap Agile dengan Arsitektur Monolith - Ziya El AriefTetap Agile dengan Arsitektur Monolith - Ziya El Arief
Tetap Agile dengan Arsitektur Monolith - Ziya El Arief
 
SOLID Design Principles for Test Automaion
SOLID Design Principles for Test AutomaionSOLID Design Principles for Test Automaion
SOLID Design Principles for Test Automaion
 
Agile Software Architecture
Agile Software ArchitectureAgile Software Architecture
Agile Software Architecture
 
He mian agile project-inception
He mian   agile project-inceptionHe mian   agile project-inception
He mian agile project-inception
 
The Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary VersionThe Open-Closed Principle - the Original Version and the Contemporary Version
The Open-Closed Principle - the Original Version and the Contemporary Version
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
Prashant technical practices-tdd for xebia event
Prashant   technical practices-tdd for xebia eventPrashant   technical practices-tdd for xebia event
Prashant technical practices-tdd for xebia event
 
1. oop with c++ get 410 day 1
1. oop with c++ get 410   day 11. oop with c++ get 410   day 1
1. oop with c++ get 410 day 1
 
Design poo my_jug_en_ppt
Design poo my_jug_en_pptDesign poo my_jug_en_ppt
Design poo my_jug_en_ppt
 
Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018Evolutionary Design - NewCrafts Paris 18 May 2018
Evolutionary Design - NewCrafts Paris 18 May 2018
 
Domain Driven Design Introduction
Domain Driven Design IntroductionDomain Driven Design Introduction
Domain Driven Design Introduction
 
Practical Enterprise Application Development
Practical Enterprise Application DevelopmentPractical Enterprise Application Development
Practical Enterprise Application Development
 
Model Driven Architectures
Model Driven ArchitecturesModel Driven Architectures
Model Driven Architectures
 
Clean Architecture
Clean ArchitectureClean Architecture
Clean Architecture
 
Agile & Secure SDLC
Agile & Secure SDLCAgile & Secure SDLC
Agile & Secure SDLC
 
Architecting Solutions and Systems – Randy’s Secrets to Success
Architecting Solutions and Systems – Randy’s Secrets to SuccessArchitecting Solutions and Systems – Randy’s Secrets to Success
Architecting Solutions and Systems – Randy’s Secrets to Success
 
L21 Architecture and Agile
L21 Architecture and AgileL21 Architecture and Agile
L21 Architecture and Agile
 
Interview preparation net_asp_csharp
Interview preparation net_asp_csharpInterview preparation net_asp_csharp
Interview preparation net_asp_csharp
 

Recently uploaded

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
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
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
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
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
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
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
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
 

Recently uploaded (20)

Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
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
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
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
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
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 ...
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
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
 

Use Design Principles to Improve Code Quality

Editor's Notes

  1. In this talk, I want to share my understanding of design thinking, agile and how to apply design principles to improve our code quality. My name is Hebin Wei, I am a member of I manage my account team.
  2. In all software developing, there are two major challenges: Doing the right thing and doing the thing right. At Liberty, we using Design thinking and the Agile process to make sure we do the right thing first.
  3. By combining the Agile and Design thinking processes together, we make sure we focus our resources on the most important thing first, getting customer feedback faster. The image on the left shows the steps of Design Thinking. It starts with researching, collecting customer requirements. Then we sort these requirements, find out customers’ pain points. Next, we define the problem. This is because sometimes customers said what they want is not what customers really need. When a customer want a drill from home depot, the drill is not what he needs, the hold on the wall is. Once we understand what customers need, we start to design and generate ideas. Next step we will pick up the best solution and build it, deploy it. This solution will be tested by customers, we will collect feedback and apply them in our next iteration. One thing I want to emphasis here is, the “Design Thinking” is not just UI design, it is solution design. We design a solution to satisfy our customers’ needs. These loops happen at different layers. At each layer, we break the big problem into smaller problems and focus on implement the solution for these smaller problems until we solve the big problem. Then the new cycle will start at a higher level.
  4. If you ever did any agile training, you probably already see this diagram. It clearly demonstrates the difference between the Agile process and a traditional waterfall process. Instead of delivering a result at the last step, the Agile process focuses on delivering an acceptable result and get customer feedback early in each loop. This diagram did a good job to explain what the Agile process is, but it also causes some misunderstandings. One argument I heard most is, “we are on an Agile process, don’t worry about the future, Let’s implement a simple solution first, we will refactor it later.”
  5. But when building software, massive refactor or rebuild from scratch is expensive. I cannot find any diagram online to demonstrate what I want, so I made one myself. I want to use this diagram to show, in the Agile process, the next phases should build on top of the previous one. Refactors should happen in small and manageable scope. I choose lego cars to show the idea that each building block should be modularized so that it can be improved or refactored independently. When we working on the current code, we should consider future refactor and extension.
  6. Before we get into how to do the thing right, let’s see some examples. These are makeup codes. These two components, show the policy title in green if it is an active policy. But the way they check the policy status is different. Now the requirements changed, the active policy’s title needs to change to blue. Just think how difficult for a new developer on board to miss one of these components.
  7. The agile process helps us break a bigger problem into smaller problems. We are more focused, but it also means we cannot see the whole picture in each loop. A smaller problem can be solved by a quick solution and many of these quick solutions end up staying.
  8. The conclusion is the Agile process needs good software design.
  9. It needs to be modularized. it should has clear layers / modular. The relative responsibility should be grouped together in a module. A module can be an npm package, a web service, a class, or a file. A module behaves like a black box. They communicate with each other using public methods, pre-defined by an interface. Except for these public methods, their implementation detail is not accessible. A good design should easy to read and understand. When a piece of code becomes hard to understand, it should be break into different modules or functions. Do not depends on operators priority, using parentheses. When choosing between an optimized but complex algorithm and an easy understanding algorithm, I will vote for the second one. Unless it is a critical method. Testing is important. Testability should be considered in software design. There are many design patterns can help. Such as Dependency injection pattern, creator patterns. Customer requirements never end, especially in the Agile process, we will never have a “completed” requirements. So our design should be prepared for changes. Reusability is the key to do little but accomplishes more. Before start coding, seeking existing code first. Implement something from scratch is expensive. The cost not just includes time, resources, but also includes finding bugs, lost customer satisfaction. When we do have to implement something new, make it reusable.
  10. As a developer, we should make sure our code works. Commit a not working code to develop is a disaster. Let others review your not working code is a waste of time. One way to help your code working is writing unit tests cover all known scenarios. Our code needs to embrace changes. Remember in the Agile process, we cannot see the whole picture. Even we do, the customers’ requirements change constantly, our code should be prepared for that. An enterprise-level software system shall have a good logging system. The logs should be traceable, allow customer support techs to easily trace a service call back to its front-end user session. Production Support BPM example: https://git.forge.lmig.com/projects/USCM-ESERVICE/repos/eservice-service-modules/browse/PmInternetAccountServiceModule/com/lmig/pm/internet/service/account/registration/RegistrationCacheManager.java#62,103,108,119,130 Traceable logs also mean able to identify the execution path of code. The example above shows how BPM code logs the enter/exiting of function. My team in my last company, a major function without enter /exit log cannot pass review. Even this, the above example still not able to link the log with the user session. There is no bug-free system. Found a bug in a software system is understandable. But what embarrassing is a known scenario not working or a fixed bug happens again. Using automation tests to cover all known scenarios and any bugs already fixed is a good way to prevent this embarrassing. The last is to keep the balance.
  11. Now we understand the Agile process needs good software design. We know what a good software design is. How do we have a good software design in the Agile process? My answer is Design Principles.
  12. The design principles help us to find out what is wrong and what is right while only see portion of the whole problem. It is a set of well defined and time verified principles. It maybe not always be the best solution, but it can help avoid the most common mistakes.
  13. The goal of design principles is to help build a good software system, which to provides values to our customers. We use design patterns to satisfy design principles. We use the CQRS pattern to separate the reading/writing responsibility, not because we need to create a Kraken service. There is no point to apply this pattern if your service only needs to read the resource.
  14. When I doling software design, I like to put the related functionalities into a group and give it a name, like policy, dataLayer, billingSystem. It is very natural for me using object-oriented design. It works well with SOLID design principles. There are some articles about the issue of object-oriented programming. Like the article posted by this guy. I think blindly accepting anyone’s idea is dangers. Instead, analyze what points make sense and apply them into our works is a better approach. I don’t think OOP is a disaster, and I don’t believe functional programming is a silly toy. They all have a place they work best and place they are not good. Use the technique at the place it works best instead of drop it completely.
  15. The object-originated design does not equal to object-originated programming. Not a Class. OOD is a way to think. It is a mindset. It is a tool to separate concerns. OOD can be implemented with OOP. But you have a lot of choices. Any language can group state and behaviors into an entity can be used to implement OOD.
  16. Single responsibility: one object should only have one responsibility. Open/ closed: Open for extension but closed for change. Liskov Substitution: When implement Polymorphism, the children implementation can extend but not modify the parent behavior. Interface segregation: the interface should be focus and small. Dependency inversion. Using interface to communicate. Do not using concrete implementation directly.
  17. Module should has purpose, and only one purpose. A module here can be a package, an object or a web service. At eservice, billing team responsibility for make a payment. At billing squad, FIN responsible for make a payment. At FIN level, they break a payment into billing request send to bank and payment received bank. payByCreditCard and payByCheck can be implemented separately. But they should be grouped together within a bigger module.
  18. Accessors can be override. A directly data access is hard to refactor. We all use lodash/get to access data. it coupled the code with the implementation detail. But it so easy to use, I like to use it.
  19. I feel this is hard to understand. Here is a good example. I don’t get how the overwrite align with this principle.
  20. Interface used to describe a role. At first round, IPersistedResource serve the need. The second round, we realized some resource is read only. So IPersistedResource divided into ILoadResource & IPresistResource The key here is don’t overkill. Seperate the role when only it need.
  21. I want to talk about dependency Inversion first. A system design should described using interfaces. Your parameter types, property types, returned data types should be interface. That is why I push our team switch to typescript. When only interact with interfaces, you will not touch implementation detail. And dependency inversion principle will automatically followed. How you implement it does not matter.
  22. First, it helps us make design decisions objectively instead of subjectively. These principles will become a checklist. It help teams using the same standard when design and review. Our decision will base on these “facts” not “feeling”. “Feeling” is different between peoples. I feel a piece of code is easy to understand, but you may not agree.
  23. Open / Close allow add new features Interface segregation limit the affected scope if something has to be changed. Lskov substitution ensure the new implementation continue to work after it replace the parent Dependency inversion will decouple the concrete implementation.
  24. Abstract method or dependency injection to allow caller extend the default behavor. Or implemented new features. The key here is when Snake or switch between EmailLogger and EventViewerLogger, I don’t need to make any change in my Animal or Customer class. I can change the my implementation inside my module if I need to.
  25. The Client represent different types of services. When they tangled together, Change Client A’s method maybe affect client B’s method. When they are defined separately, I will feel more confident to make change for Client A. Also when I need to pull each client’s service into it own service host, it can easily do it. CIP also make the client side easier. Because Client A only care about the Service A interface, when Service A moved to its own instance, Client A don’t need to change. You don’t know when you service need to be break into separate services. ICP will prepare you for that.
  26. One responsibility only handle by one object, and one object only has one responsibility make code easy to trace. Interface segregation help focus on the main logic when reading code. Dependency inversion prevent code noises when reading code.
  27. More focused responsibility make code easy to understand. Because more focused.
  28. I only talk to the interface I need. I don’t care how you connected together behind.
  29. Don't care how it was implemented, Only interact through interface. x
  30. Single responsibility, the less path, the easier to set up some checkpoints. Interface segregation make test suite small and focus. Dependency inversion allow use same test suites to test multiple implementation. Because the tests is depended on abstraction layer tool. To test different implementation, just switch the concrete object to test.