Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tips on creating clean, elegant code [closed]

Tags:

architecture

Writing clean, elegant code is what makes coding a pleasure for me. I'm always looking for more ways to do so. Here are some of my strategies/tactics:

  • Keep large code blocks in smaller chunks of routines/methods/classes

  • Be sure every routine has one point of exit. Exit loops with logic at the top of the loop, not with breaks or some type of "exit loop" keyword.

  • Avoid globals

  • If you just performed a copy/paste with your code, it is time to create a routine/class/library.

...and one I've been toying with lately:

  • Try to replace if/branching/select cases with different method signatures (polymorphism) Clean Code Talks on YouTube
like image 267
DeveloperMCT Avatar asked Nov 28 '22 10:11

DeveloperMCT


1 Answers

Clean Code by Robert C. Martin

alt text

like image 106
Chuck Conway Avatar answered Dec 07 '22 19:12

Chuck Conway