SlideShare a Scribd company logo
1 of 19
Download to read offline
PRINCIPLES
OF

GOOD
PROGRAMMING
Presentation By
Angelin
@ardentlearner
DRY

DON’T REPEAT YOURSELF
I will not repeat myself
I will not repeat myself
I will not repeat myself
I will not repeat myself
I will not repeat myself
I will not repeat myself
REPETITION IS THE ROOT OF ALL SOFTWARE EVIL

As soon as you start repeating yourself (e.g. a long expression, a
series of statements, same concept) create a new abstraction.
@ardentlearner

1
ABSTRACT
Each significant piece of functionality in a program should be
implemented in just one place in the source code.
Main Problem

1st layer abstraction

2nd layer abstraction

3rd layer abstraction
@ardentlearner

2
KISS
Always remember to…

KISS
KEEP

IT

SIMPLE

STUPID

Simplicity (and avoiding complexity) should always be a key goal.
Simple code takes less time to write, has fewer bugs and is easier
to modify.

@ardentlearner

3
YAGNI
Avoid Creating a YAGNI
(You aren’t going to need it)

You should try not to add
functionality until you need it.
Pain

“Hey,
we could …”

YAGNI

The simplest
thing that could
possibly work

No Pain
@ardentlearner

4
SIMPLE

IT’S THE
THINGS
THAT MAKE A
Do the simplest thing that could possibly work.
A good question to ask one’s self when programming is,
“What is the simplest thing that could possibly work?”
This helps keep us on the path towards simplicity in the design.
@ardentlearner

5
DON’T MAKE ME THINK

The code should be easily read and understood with a
minimum of effort required.

If code requires too much thinking from an observer to
understand, then it can probably stand to be simplified.
@ardentlearner

6
OPEN / CLOSED
OPEN

MODIFICATION

FOR
EXTENSION
CLOSED

Software entities (classes, modules, functions, etc.) should be
open for extension,
but
closed for modification.
In other words, do not write classes that people can modify.
Write classes that people can extend.
@ardentlearner

7
MAINTAINABLE
Write Code for the Maintainer
Almost any code that is worth
writing is worth maintaining in
the future.

WRITE YOUR

AS IF THE PERSON
MAINTAINING IT
IS A
HOMICIDAL
MANIAC

WHO KNOWS
WHERE YOU LIVE
@ardentlearner

8
LEAST ASTONISHMENT

Code should surprise the reader as little as possible.
This means following standard coding conventions and
the code should do what the comments and name suggest and any
potentially surprising side effects should be avoided as much as
possible.
@ardentlearner

9
SINGLE RESPONSIBILITY

A component of code (e.g. class or function) should perform a
single well defined task.
@ardentlearner

10
MINIMIZE COUPLING

“All modules should be independent as far as possible”
Improves maintainability
@ardentlearner

11
MAXIMIZE COHESION

“Things that belong together should be kept together”
Makes code easier to understand, debug and test.
@ardentlearner

12
THE LAW OF DEMETER
Talk only to your closest friends

THE LAW OF DEMETER
is also known as
Principle of Least Knowledge
@ardentlearner

13
AVOID PREMATURE OPTIMIZATION

Don’t even think about optimization unless your code is working
but slower than you want. Only then should you start thinking
about optimizing and only with the aid of empirical data.
"We should forget about small efficiencies, say about 97% of the time:
Premature Optimization is the root of all evil" - Donald Knuth.
@ardentlearner

14
REUSE CODE

Reusing code
improves code reliability
and
decreases development time.
@ardentlearner

15
SEPARATION OF CONCERNS

Different areas of functionality should be managed by
distinct and minimally overlapping modules of code.
@ardentlearner

16
EMBRACE CHANGE

@ardentlearner

17
HAPPY
PROGRAMMING !

@ardentlearner

More Related Content

What's hot

Chat in language teaching
Chat in language teachingChat in language teaching
Chat in language teaching
sarymuz
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
Roger Argarin
 

What's hot (20)

Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)Vim Editor And Basic Scripting (Ch-7)
Vim Editor And Basic Scripting (Ch-7)
 
Introduction of .net framework
Introduction of .net frameworkIntroduction of .net framework
Introduction of .net framework
 
Silent way method
Silent way methodSilent way method
Silent way method
 
Lua - Programming Language
Lua - Programming LanguageLua - Programming Language
Lua - Programming Language
 
Chat in language teaching
Chat in language teachingChat in language teaching
Chat in language teaching
 
Whole Language Approach
Whole Language ApproachWhole Language Approach
Whole Language Approach
 
Programming Fundamentals lecture 1
Programming Fundamentals lecture 1Programming Fundamentals lecture 1
Programming Fundamentals lecture 1
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
CSS selectors
CSS selectorsCSS selectors
CSS selectors
 
Algorithmic problem sloving
Algorithmic problem slovingAlgorithmic problem sloving
Algorithmic problem sloving
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
JAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptxJAVASCRIPT PPT [Autosaved].pptx
JAVASCRIPT PPT [Autosaved].pptx
 
Types of Programming Languages
Types of Programming LanguagesTypes of Programming Languages
Types of Programming Languages
 
Laravel Blade Template
Laravel Blade TemplateLaravel Blade Template
Laravel Blade Template
 
4_5949547032388570388.ppt
4_5949547032388570388.ppt4_5949547032388570388.ppt
4_5949547032388570388.ppt
 
System programming
System programmingSystem programming
System programming
 
Coding standard
Coding standardCoding standard
Coding standard
 
How to Work with Dev-C++
How to Work with Dev-C++How to Work with Dev-C++
How to Work with Dev-C++
 
Introduction to VB.net
Introduction to VB.netIntroduction to VB.net
Introduction to VB.net
 
Unit 3 lecture-2
Unit 3 lecture-2Unit 3 lecture-2
Unit 3 lecture-2
 

Similar to The principles of good programming

Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
John Choi
 
Culture And Aesthetic Revisited
Culture And Aesthetic RevisitedCulture And Aesthetic Revisited
Culture And Aesthetic Revisited
Adam Keys
 
You shouldneverdo
You shouldneverdoYou shouldneverdo
You shouldneverdo
daniil3
 
festival ICT 2013: Ruby, the 0.8 language you were looking for
festival ICT 2013: Ruby, the 0.8 language you were looking forfestival ICT 2013: Ruby, the 0.8 language you were looking for
festival ICT 2013: Ruby, the 0.8 language you were looking for
festival ICT 2016
 

Similar to The principles of good programming (20)

Most valuable software design principles
Most valuable software design principlesMost valuable software design principles
Most valuable software design principles
 
30% faster coder on-boarding when you have a code cookbook
30% faster coder on-boarding when you have a code cookbook30% faster coder on-boarding when you have a code cookbook
30% faster coder on-boarding when you have a code cookbook
 
Software Development Essential Skills
Software Development Essential SkillsSoftware Development Essential Skills
Software Development Essential Skills
 
YAGNI Principle and Clean Code
YAGNI Principle and Clean CodeYAGNI Principle and Clean Code
YAGNI Principle and Clean Code
 
Best pratice
Best praticeBest pratice
Best pratice
 
How have we developed product without bugs
How have we developed product without bugsHow have we developed product without bugs
How have we developed product without bugs
 
Best Practices For Writing Super Readable Code
Best Practices For Writing Super Readable CodeBest Practices For Writing Super Readable Code
Best Practices For Writing Super Readable Code
 
7 rules on code readability
7 rules on code readability7 rules on code readability
7 rules on code readability
 
Culture And Aesthetic Revisited
Culture And Aesthetic RevisitedCulture And Aesthetic Revisited
Culture And Aesthetic Revisited
 
Simple is the best
Simple is the bestSimple is the best
Simple is the best
 
10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming10 tips to save you time and frustration while programming
10 tips to save you time and frustration while programming
 
You shouldneverdo
You shouldneverdoYou shouldneverdo
You shouldneverdo
 
Java
JavaJava
Java
 
festival ICT 2013: Ruby, the 0.8 language you were looking for
festival ICT 2013: Ruby, the 0.8 language you were looking forfestival ICT 2013: Ruby, the 0.8 language you were looking for
festival ICT 2013: Ruby, the 0.8 language you were looking for
 
Clean Code
Clean CodeClean Code
Clean Code
 
Agile mindset
Agile mindsetAgile mindset
Agile mindset
 
Refactoring page objects The Screenplay Pattern
Refactoring page objects   The Screenplay Pattern Refactoring page objects   The Screenplay Pattern
Refactoring page objects The Screenplay Pattern
 
Good programming
Good programmingGood programming
Good programming
 
Writing Clean Code
Writing Clean CodeWriting Clean Code
Writing Clean Code
 
2.1.8 clean code and debugging
2.1.8 clean code and debugging2.1.8 clean code and debugging
2.1.8 clean code and debugging
 

More from Angelin R

Agile SCRUM Methodology
Agile SCRUM MethodologyAgile SCRUM Methodology
Agile SCRUM Methodology
Angelin R
 
Exception handling and logging best practices
Exception handling and logging best practicesException handling and logging best practices
Exception handling and logging best practices
Angelin R
 
Tamil Christian Worship Songs
Tamil Christian Worship SongsTamil Christian Worship Songs
Tamil Christian Worship Songs
Angelin R
 

More from Angelin R (17)

Comparison of Java Web Application Frameworks
Comparison of Java Web Application FrameworksComparison of Java Web Application Frameworks
Comparison of Java Web Application Frameworks
 
[DOC] Java - Code Analysis using SonarQube
[DOC] Java - Code Analysis using SonarQube[DOC] Java - Code Analysis using SonarQube
[DOC] Java - Code Analysis using SonarQube
 
Java Source Code Analysis using SonarQube
Java Source Code Analysis using SonarQubeJava Source Code Analysis using SonarQube
Java Source Code Analysis using SonarQube
 
Exception handling & logging in Java - Best Practices (Updated)
Exception handling & logging in Java - Best Practices (Updated)Exception handling & logging in Java - Best Practices (Updated)
Exception handling & logging in Java - Best Practices (Updated)
 
A Slice of Me
A Slice of MeA Slice of Me
A Slice of Me
 
Team Leader - 30 Essential Traits
Team Leader - 30 Essential TraitsTeam Leader - 30 Essential Traits
Team Leader - 30 Essential Traits
 
Action Script
Action ScriptAction Script
Action Script
 
Agile SCRUM Methodology
Agile SCRUM MethodologyAgile SCRUM Methodology
Agile SCRUM Methodology
 
Exception handling and logging best practices
Exception handling and logging best practicesException handling and logging best practices
Exception handling and logging best practices
 
Tamil Christian Worship Songs
Tamil Christian Worship SongsTamil Christian Worship Songs
Tamil Christian Worship Songs
 
Flex MXML Programming
Flex MXML ProgrammingFlex MXML Programming
Flex MXML Programming
 
Introduction to Adobe Flex
Introduction to Adobe FlexIntroduction to Adobe Flex
Introduction to Adobe Flex
 
Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)Software Development Life Cycle (SDLC)
Software Development Life Cycle (SDLC)
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
Effective Team Work Model
Effective Team Work ModelEffective Team Work Model
Effective Team Work Model
 
Team Building Activities
Team Building ActivitiesTeam Building Activities
Team Building Activities
 
XStream
XStreamXStream
XStream
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

The principles of good programming

  • 2. DRY DON’T REPEAT YOURSELF I will not repeat myself I will not repeat myself I will not repeat myself I will not repeat myself I will not repeat myself I will not repeat myself REPETITION IS THE ROOT OF ALL SOFTWARE EVIL As soon as you start repeating yourself (e.g. a long expression, a series of statements, same concept) create a new abstraction. @ardentlearner 1
  • 3. ABSTRACT Each significant piece of functionality in a program should be implemented in just one place in the source code. Main Problem 1st layer abstraction 2nd layer abstraction 3rd layer abstraction @ardentlearner 2
  • 4. KISS Always remember to… KISS KEEP IT SIMPLE STUPID Simplicity (and avoiding complexity) should always be a key goal. Simple code takes less time to write, has fewer bugs and is easier to modify. @ardentlearner 3
  • 5. YAGNI Avoid Creating a YAGNI (You aren’t going to need it) You should try not to add functionality until you need it. Pain “Hey, we could …” YAGNI The simplest thing that could possibly work No Pain @ardentlearner 4
  • 6. SIMPLE IT’S THE THINGS THAT MAKE A Do the simplest thing that could possibly work. A good question to ask one’s self when programming is, “What is the simplest thing that could possibly work?” This helps keep us on the path towards simplicity in the design. @ardentlearner 5
  • 7. DON’T MAKE ME THINK The code should be easily read and understood with a minimum of effort required. If code requires too much thinking from an observer to understand, then it can probably stand to be simplified. @ardentlearner 6
  • 8. OPEN / CLOSED OPEN MODIFICATION FOR EXTENSION CLOSED Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification. In other words, do not write classes that people can modify. Write classes that people can extend. @ardentlearner 7
  • 9. MAINTAINABLE Write Code for the Maintainer Almost any code that is worth writing is worth maintaining in the future. WRITE YOUR AS IF THE PERSON MAINTAINING IT IS A HOMICIDAL MANIAC WHO KNOWS WHERE YOU LIVE @ardentlearner 8
  • 10. LEAST ASTONISHMENT Code should surprise the reader as little as possible. This means following standard coding conventions and the code should do what the comments and name suggest and any potentially surprising side effects should be avoided as much as possible. @ardentlearner 9
  • 11. SINGLE RESPONSIBILITY A component of code (e.g. class or function) should perform a single well defined task. @ardentlearner 10
  • 12. MINIMIZE COUPLING “All modules should be independent as far as possible” Improves maintainability @ardentlearner 11
  • 13. MAXIMIZE COHESION “Things that belong together should be kept together” Makes code easier to understand, debug and test. @ardentlearner 12
  • 14. THE LAW OF DEMETER Talk only to your closest friends THE LAW OF DEMETER is also known as Principle of Least Knowledge @ardentlearner 13
  • 15. AVOID PREMATURE OPTIMIZATION Don’t even think about optimization unless your code is working but slower than you want. Only then should you start thinking about optimizing and only with the aid of empirical data. "We should forget about small efficiencies, say about 97% of the time: Premature Optimization is the root of all evil" - Donald Knuth. @ardentlearner 14
  • 16. REUSE CODE Reusing code improves code reliability and decreases development time. @ardentlearner 15
  • 17. SEPARATION OF CONCERNS Different areas of functionality should be managed by distinct and minimally overlapping modules of code. @ardentlearner 16