Read a lot of code, some people write more than 5 years of code, but the code is too bad to read directly to people. Someone wrote the code to make people read the feast for the eyes, why the gap between people so big?
It seems that how to write good code is a very worthwhile thing to say.
Key ideas:
- People write code that is intended for others to read, not to be executed by the machine. Writing code should be like writing a novel, making people read easily and happily.
- During the lifetime of the software, the maintenance cycle accounts for more than 1, so don't look to avoid someone changing your code
- If you change jobs, your code needs someone else to take over.
- If your own code, 3 days later you can not understand
- The bull's code always makes you want to put it down.
- Write code needs to pay attention to the level of consistency, not sesame and watermelon mixed together.
- Stool, table, chair, molecule, bed, you think that's wrong.
- Give another example of cooking:
- Wash vegetables
- Cut vegetables
- Pour oil stir fry
- The oil temperature slowly rises from 10 degrees to 60C, the gap between the oil molecules is getting bigger and the oil boiling up. There was a reaction between the oil molecule and the vegetable molecule.
- Out of the pot.
- Each level is responsible for its own 7 sub-nodes below.
- Do not have too many comments, you note that you are afraid that others can not understand.
- The more comments I take, the more serious I am, but one day the code changes and the comment hurts.
- Only need to sketch into Doc's notes
- Method names, arguments, and class names themselves are comments
- A team must have a consistent coding style, if someone can't unify, Maverick, then out.
- I want to be free, I am the wind of the unruly, I will scrape away immediately
- My cow, so I don't have to obey, sorry, really cow?
- My previous company had no coding specifications, and that was silly of them.
- To have best practices, this can significantly improve code quality
- Like effective Java.
- such as "abc". Equals (XXX)
Have time to read refactoring, code encyclopedia, you will fall in love with coding, writing poetry general code.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Architect Express 6.9-How to write good code