Wednesday, March 4, 2015

Writing Clean Code

I accumulated some reference

1. Put good comments on SVN, like what you want to test.  Retain those code that might be used again in the svn, and delete it from your code to keep it clean.
2. When you want to try a new function, a good way is to create a new class. Not create a new function in the class, that will make the class looks too bloat.
3. When the function is working, congrats keep it for the paper. If not, just delete it (note that the version still contain in SVN).
4. People says read code vs write code, times is 10 vs 1. Can't agree on that more. When you create a new class, try a new algorithm, try to record your idea somewhere (written in comment, if too complex a video). so that you can recall it. When you define a function, comments on its purpose and so on.
5. When trying a parameter, define it at a centre place. Cleaning the parameters once in a while.
6. Should have a rule on variable naming. And be consistent on it.
7. Test-driven development will save you lots of time finding bugs, and recreate the same test case. Write unit-test forefront.
8. Define some common libraries when you are coding, and find yourself code the same thing over and over again. Replace all codes with the libraries code for easiness of maintainence.