0
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 my...
ABSTRACT
Each significant piece of functionality in a program should be
implemented in just one place in the source code.
...
KISS
Always remember to…

KISS
KEEP

IT

SIMPLE

STUPID

Simplicity (and avoiding complexity) should always be a key goal....
YAGNI
Avoid Creating a YAGNI
(You aren’t going to need it)

You should try not to add
functionality until you need it.
Pai...
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...
DON’T MAKE ME THINK

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

If code requires to...
OPEN / CLOSED
OPEN

MODIFICATION

FOR
EXTENSION
CLOSED

Software entities (classes, modules, functions, etc.) should be
op...
MAINTAINABLE
Write Code for the Maintainer
Almost any code that is worth
writing is worth maintaining in
the future.

WRIT...
LEAST ASTONISHMENT

Code should surprise the reader as little as possible.
This means following standard coding convention...
SINGLE RESPONSIBILITY

A component of code (e.g. class or function) should perform a
single well defined task.
@ardentlear...
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.
...
THE LAW OF DEMETER
Talk only to your closest friends

THE LAW OF DEMETER
is also known as
Principle of Least Knowledge
@ar...
AVOID PREMATURE OPTIMIZATION

Don’t even think about optimization unless your code is working
but slower than you want. On...
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 o...
EMBRACE CHANGE

@ardentlearner

17
HAPPY
PROGRAMMING !

@ardentlearner
Upcoming SlideShare
Loading in...5
×

The principles of good programming

416

Published on

The Principles of Good Programming

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
416
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
18
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Transcript of "The principles of good programming"

  1. 1. PRINCIPLES OF GOOD PROGRAMMING Presentation By Angelin @ardentlearner
  2. 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. 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. 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. 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. 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. 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. 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. 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. 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. 11. SINGLE RESPONSIBILITY A component of code (e.g. class or function) should perform a single well defined task. @ardentlearner 10
  12. 12. MINIMIZE COUPLING “All modules should be independent as far as possible” Improves maintainability @ardentlearner 11
  13. 13. MAXIMIZE COHESION “Things that belong together should be kept together” Makes code easier to understand, debug and test. @ardentlearner 12
  14. 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. 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. 16. REUSE CODE Reusing code improves code reliability and decreases development time. @ardentlearner 15
  17. 17. SEPARATION OF CONCERNS Different areas of functionality should be managed by distinct and minimally overlapping modules of code. @ardentlearner 16
  18. 18. EMBRACE CHANGE @ardentlearner 17
  19. 19. HAPPY PROGRAMMING ! @ardentlearner
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×