The following is a 14-point experience in developing high-efficiency programming, Daniel concludes. Whether you are a novice programmer or a senior programmers, you may be inspired.
1. Planning
Plan, in fact, is the "design" phase of programming, and of course, the plan here is not as heavyweight as design. It requires US programmers to consider the following issues at least before formal programming:
What is the purpose of your program, tool or project, and what is it used for? You can do well and do the right thing only if you know what to do and what you want to achieve.
What kind of functionality is required. Need you to give out a function sheet. This will ensure that we don't miss out on anything.
Prepare pre-survey and solution for some technical problems. Don't wait until you start programming.
Here are some of the benefits you get from "plan":
Can you clearly understand what you are going to do?
Do you know exactly what you're going to do with your development?
You can solve all of your potential problems in the development project.
2. Using pseudo-code
Pseudocode is a great way to see what your program looks like.
Some people do not like pseudocode, because they do not want to write the same code two times, again is pseudo code, again is the real code. In fact, this is understandable, because two copy of the things are relatively poor maintenance. But I think, this can be weighed, if the algorithm is very simple, then there is no need for pseudo-code, if your algorithm is more complex, compared around, then, there is a pseudo code sketchy will be a very good thing, because he is helpful to let others from a simple document to understand a complex algorithm or system. It's like a wiring diagram of a wire, and you can easily find a clue from a complex implementation with a simple document.
3. Write a clear note
Please write a clear program note in your code. Of course, the more comments are not the better, the comments should be concise , and if your program is sufficiently clear and simple, then the annotations will be superfluous. In addition, the comment should be a comment "cause, reason, purpose," rather than the comment "what".
4. Use the automatic editing tool
There are many automatic editing tools, such as Typinator, which can be used to set up a few alternative simple code to implement the quick insertion of repeated statements, such as your own signature, common statements, etc., through which you can set the replacement of the short code. There are other tools for automating the code, such as some VC plugins, and something like source Insight. Don't underestimate this point of time, if you write code every day, a little today, a little tomorrow, will save you a lot of time.
5. Reduce the Code
Reduce the number of codes, stick to DRY(Don ' t Repeat yourself) and KISS(Keep It Simple & Stupid) principles. This can be done to reduce the complexity of the code, to improve the readability and maintainability of the program, but also to increase the quality of the code
6. Code Reuse
The DRY (don ' t repeat yourself) principle is to tell us that we need to reuse existing code. In this way, you can stand on the shoulders of giants and thus be able to focus more on the logic of the business you are dealing with. The highest level of programming is that the code that is written is likely to be reused, reused, and generic, which is the goal that is always pursued in programming.
7. Code Refactoring
Some old code may be outdated, compared to the old C + + STL library in multi-threaded may have a lot of problems. So, our own code is the same, every time, we need to recycle the code, this is the software refactoring. Refactoring code is not to provide more functionality, but to make the old code more vitality, so that the old code to keep up with the times, more extensibility, flexibility.
8. Use design mode
Design patterns are a methodology for solving some problems from a code level. There are many design patterns in the world, such as MVC, single instance, factory, observer, etc. Using a good design pattern can make your code more reusable and extensible.
9. Using the framework of the program frame
Frameworks is a gift to programmers who help you with a lot of detail, they can be a Lib library, you need to do a simple assembly, a nearly completed software framework has been formed. This is a thing that can speed up the development work. Just surf the internet and you can see too many frames. Almost all of them are contributed by the open source community.
10. Generic Programming
It is one of the highest realms of programming, such as STL in C + +, which is the best embodiment of such things, if it is like something similar in a program, and then the same thing is done with a standard thing. Flexible and almost all of them are on the right.
11. Using Open Source code
There are too many open source code in this world. Learn to use them can save you time and energy, because we do not have to achieve the equivalent of a number of times, learn to use open source code is not only a learning process, but also an increase in programming efficiency of things.
12. Improve the development environment
The development environment is important because a good development environment can make you more inefficient. They can make you don't need to focus on something else, for example, I've seen a programmer spend a lot of time tweaking the font and highlighting of the editor. Yes, this is worth affirming, only to make the development environment comfortable, so that they can better programming.
13. Using the Debugger
Learn to use the debugger to debug code, single-step tracking, variable value tracking, memory, stacks, and more. Skilled use of the debugger allows you to better find the problem of the program in order to get the best code.
14. Using Version management Tools
The version management tool should be something that any programmer should learn to use, especially in a team, how to manage different versions of the program, how to maintain it, store the code, and the version management tool is absolutely essential to the development process. The meaning is absolutely not just code backup and sharing.
14 Tips for programmer-efficient programming