To write beautiful code, you need to know how to write it really well. Thousands of feng Xiaobian for everyone to sort out a few ways to help you write code more handy:

1. Think before you code

Take 10, 20, or even 30 minutes to think about what you need and what design patterns are appropriate for what you’re going to code. You’ll be glad you “wasted” those minutes, and when you have to change or add something to the code you won’t be wasting minutes but spending more time.

2. Comment your code

Seriously, there’s nothing worse than checking your code two months later and not remembering what it was used for. Note all the important stuff, but leave out the obvious.

Write clean code

Well-proportioned. Use Spaces. Modularize your code according to functionality. It is very helpful to read CleanCode by Robert c. Martin. Also, follow code conventions/standards (such as JavaCodeConventions), especially if the code is shared.

4. Reconstruction

No one likes to use those super-long methods. This usually (and almost always) means you’re mixing up features. Separate the code in a more manageable way. It also makes your code more reusable.

5. Don’t copy and paste code

If you have two or more identical blocks of code, then you’re probably doing something wrong. Read No. 4.

6. Use meaningful names

Although naming int variables as “elligent” or char as “mander” is funny; However, such a name does not tell you what the variable is used for.

7. Test code

Test, test, test, test. Test your code. Don’t wait until you’ve finished the program to test it, or you’ll regret it when you find a huge bug and don’t know where it came from.

Automated tests are often valuable. It also helps save a lot of time on retesting and regression testing.

8. Learn to debug

Used to managing things without knowing how to do it, and println every time you have a problem. Big mistake. Sometimes, bugs aren’t even found, and checking for “missing” printlns is a waste of time. Debugging can not only find application defects, but also fix them. For Java programmers, they need to learn not only how to develop decent programs, but also how to debug them.

The above is thousand feng xiaobian to help you improve work efficiency skills, you might as well try in the usual coding process, help you write beautiful code,!