Good code

385 views

Published on

Before we land up programming lets understand the "Good Practices of Coding"

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

  • Be the first to like this

No Downloads
Views
Total views
385
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Good code

  1. 1. Writing good code
  2. 2. Purpose 1: Software development is a group effort1. Lots of people are involved2. Code is revisited very often3. Cost of maintenance
  3. 3. Purpose 2: Code has to last longCodebase is discarded when1. It is not understood2. It is not robust3. It is not extensible4. It is not efficient
  4. 4. What writing good code has got to do with sitting inconference room?1. To make you sensible to the topic2. To set you on right path
  5. 5. So lets get started with the session!
  6. 6. Be sensible1. Readability: clarity over cleverness2. Consistency3. Cyclomatic complexity4. Responsible while changing code
  7. 7. Be robust1. Least astonishmenta. No side effectsb. Re factor2. Use correct data typesa. Makes code more maintainableb. re-factoring is easy3. Scope variables carefullya. Dont spoil global name spaceb. Dont reuse convenient variables/constants
  8. 8. Be Pragmatic1. See the big picturea. composition/cohesion – Design by contract2. Understand the platforma. memory model: String builder, boxing/unboxingb. memory leaksc. thread safety
  9. 9. Points to ponder1. Error – To catch or not to catch2. Exception model - http://c2.com/cgi/wiki?UseExceptionsInsteadOfErrorValues3. overloading - dont overload it4. Out of band info5. Boy scout principle6. Dont re-invent, evolve
  10. 10. Suggested reading1. Art of Unix programming - http://www.faqs.org/docs/artu/2. Unmaintainable code - http://mindprod.com/jgloss/unmain.html3. http://c2.com/cgi/fullSearch?search=4. Pragmatic programmer5. 97 things every programmer should know6. Clean code

×