4 May 2022, 07:02
cleaner code
Make your code as readable, code is for humans!
- Use long, descriptive names
- Divide the code into logical subroutines
- Keep it simple when possible - there are no points for complicated one liner solutions
The creation cycle
- Make it work
- Make it right
- Make it beautiful and fast
Spend a lot of time reading and understanding a complex piece of code you might be interacting with
- Jumping to code when you do not understand what's happening around will almost always result in an inefficient solution
Use debuggers extensively.
- Understand input fast: put a break point, play around with methods on your input
- Sandbox: Quickly implement a solution in the watch/console section instead of rerunning the whole program
- Debug: Understand the state of the program and fix it up
Write tests
- It's better to fail early and fix the problem than fail in production.
- Every time you refactor, change, or add to your code, your tests will make sure you did not regress.
- Add tests at every opportunity
Referene
Twitter thread by Ujjwal Chadha