philosophy of coding

18
PHILOSOPHY OF CODING

Upload: hawa

Post on 07-Jan-2016

23 views

Category:

Documents


0 download

DESCRIPTION

PHILOSOPHY OF CODING. An untidy room is like bad code: you spend hours in finding things and when you try to add something you are just adding mess. A tidy room is like good code: you immediately find things, and you can easily change the way they are organized. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: PHILOSOPHY OF CODING

PHILOSOPHY OF CODING

Page 2: PHILOSOPHY OF CODING

An untidy room is like bad code: you spend hours in finding things and when you try to add something you are just adding mess.

Page 3: PHILOSOPHY OF CODING

A tidy room is like good code: you immediately find things, and you can easily change the way they are organized.

Page 4: PHILOSOPHY OF CODING

The speed of development is related to costs. The speed of development can increase over time as you indulge in bad practices. It can improve with refactoring.

Page 5: PHILOSOPHY OF CODING

The speed of development is not just the time you spend to develop a certain functionality, but the time others will spend in adding functionalities to your code.

Page 6: PHILOSOPHY OF CODING

A maintainable code can easily be changed, reduce the costs, has a limited number of bugs, and... make the developers more happy!

Page 7: PHILOSOPHY OF CODING

The big question

How to write maintainable code?

Page 8: PHILOSOPHY OF CODING

Remember: smart is the one who can see far away, but in the only direction allowed by the blinders. Wise is the one who can turn his head 360 degrees.

Don't be intelligent when you code. Be wise!

Page 9: PHILOSOPHY OF CODING

First principle: design before coding.

The more time you spend on design, the less time you will spend on debugging.

Page 10: PHILOSOPHY OF CODING

Second principle: understand the functionality before coding or bug

fixing. If you understand the functionality, the code will

be an open book.

Page 11: PHILOSOPHY OF CODING

Third principle: be simple!

Find the simplest solution for the complexity you have to deal with. Complex solutions or not normalized schemas will add complexity exponentially along the development process. When you have to change something unnecessarily complex, you will resort to a quadratic complex trick.

Page 12: PHILOSOPHY OF CODING

Fourth principle: separation of concerns to avoid spaghetti code.

Separation of concerns is mainly achieved by encapsulating.

When a change affect only one part of your code, it's easy to add functionalities.

Spaghetti code means that when you touch something, the entire castle of cards collapse on itself.

Page 13: PHILOSOPHY OF CODING

When you puncture a tire, you can easily substitute it. With spaghetti-code, you would have to buy a new car.

Page 14: PHILOSOPHY OF CODING

Indicator of a good code (not spaghetti-code style!)

The time spent in reading and understanding the code or the time spent in bug fixing should be low, compared to the time spent in coding.

Page 15: PHILOSOPHY OF CODING

Fifth principle: code reuse.

"One of the attributes that most strongly distinguishes expert programmers from less experienced ones is that experts strive for and usually achieve a high degree of code reuse" (by Joshua Bloch, Effective Java)

That include writing atomic functions, which promotes code reuse.

Page 16: PHILOSOPHY OF CODING

Good code is always maintainable, bad code is always unmaintainable.

Page 17: PHILOSOPHY OF CODING

The pyramid of good coding

Page 18: PHILOSOPHY OF CODING

Final truth

The universe is actually terribly simple, unfortunately explaining things in a complex way is just as easy.