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

How to save on software maintenance costs
How to save on software maintenance costsHow to save on software maintenance costs
How to save on software maintenance costs
FrancisJansen
 
Software quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiranSoftware quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiran
Tanmi Kapoor
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
NSU-Biliran Campus
 
Lecture 15 requirements modeling - scenario, information and analysis class...
Lecture 15   requirements modeling - scenario, information and analysis class...Lecture 15   requirements modeling - scenario, information and analysis class...
Lecture 15 requirements modeling - scenario, information and analysis class...
IIUI
 

What's hot (20)

Qbasic Tutorial
Qbasic TutorialQbasic Tutorial
Qbasic Tutorial
 
Software Evolution
Software EvolutionSoftware Evolution
Software Evolution
 
Chapter 01 software engineering pressman
Chapter 01  software engineering pressmanChapter 01  software engineering pressman
Chapter 01 software engineering pressman
 
Dbms Lecture Notes
Dbms Lecture NotesDbms Lecture Notes
Dbms Lecture Notes
 
DBMS
DBMSDBMS
DBMS
 
How to save on software maintenance costs
How to save on software maintenance costsHow to save on software maintenance costs
How to save on software maintenance costs
 
Introduction to Java
Introduction to JavaIntroduction to Java
Introduction to Java
 
Dbms notes
Dbms notesDbms notes
Dbms notes
 
extreme Programming
extreme Programmingextreme Programming
extreme Programming
 
Ch 3 Assembler in System programming
Ch 3 Assembler in System programming Ch 3 Assembler in System programming
Ch 3 Assembler in System programming
 
Characteristics of Software
Characteristics of SoftwareCharacteristics of Software
Characteristics of Software
 
Software quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiranSoftware quality metrics methodology _tanmi kiran
Software quality metrics methodology _tanmi kiran
 
Devices Management
Devices ManagementDevices Management
Devices Management
 
computer memory and memory module
computer memory and memory modulecomputer memory and memory module
computer memory and memory module
 
Introduction to computer programming
Introduction to computer programmingIntroduction to computer programming
Introduction to computer programming
 
State of Emoji Report 2022
State of Emoji Report 2022State of Emoji Report 2022
State of Emoji Report 2022
 
Java notes
Java notesJava notes
Java notes
 
Java
JavaJava
Java
 
Lecture 15 requirements modeling - scenario, information and analysis class...
Lecture 15   requirements modeling - scenario, information and analysis class...Lecture 15   requirements modeling - scenario, information and analysis class...
Lecture 15 requirements modeling - scenario, information and analysis class...
 
Software Engineering
Software Engineering Software Engineering
Software Engineering
 

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

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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