Tips for Writing Better Code

7
Tips for Writing Better Code Jamshid Hashimi Co-Founder, CodeZone

Transcript of Tips for Writing Better Code

Page 1: Tips for Writing Better Code

Tips for Writing Better Code

Jamshid Hashimi

Co-Founder, CodeZone

Page 2: Tips for Writing Better Code

Agenda

• Why Better Code?

• Tips

Page 3: Tips for Writing Better Code

Why Better Code?

• Writing better code is a universal subject in the world of computer programming.• Readability (for you and anyone else who has look into your code)

• Maintainability (easy to modify)

• Simplicity (not complicating things when there's no need for that)

• Efficiency (of course your code should execute fast)

• Clarity (if your code is self-explanatory, there's no need for comments most of the time, name your methods/properties etc. sensibly, break the long code down, never copy & paste a block of code)

Page 4: Tips for Writing Better Code

Tips

• Commenting & Documentation• @author, @category, @link, @license, @package, @since, @version and

more at http://www.phpdoc.org/docs/latest/index.html

• Consistent Indentation

• Avoid Obvious Comments

• Code Grouping

• Consistent Naming Scheme

• Avoid Deep Nesting

Page 5: Tips for Writing Better Code

Tips

• Limit Line Length

• File and Folder Organization

• Capitalize SQL Special Words

• Use revision control for your code

• Write good and detailed commit messages

Page 6: Tips for Writing Better Code

Tips

• Know your editor

• Automate all repetitive tasks (DRY Principle)

• Refactor every so often

• Allow time for learning

• Watch talks and presentations

• Read Open Source Code

Page 7: Tips for Writing Better Code

Thank You!