14 suggestions for efficient programming for programmers

Source: Internet
Author: User

Overview: The following is a 14-Point experience of efficient programming summarized by developers.

The following is a 14-Point experience of efficient programming summarized by developers. You may be inspired by cainiao or senior programmers.

  1. Plan

The so-called plan is actually the "design" stage in programming. Of course, the plan here is not as heavyweight as the design. It requires our programmers to consider the following issues at least before formal programming:

  • What is the purpose of your program, tool, or project. Only by knowing what to do and what to do can you do well and do right.
  • What functions are required. You need to provide a menu. This ensures that we will not miss anything.
  • Prepare preliminary surveys and solutions for some technical difficulties. Don't wait until you start programming.

The following are the benefits you get from the "Plan:

  • You can clearly understand what you want to do?
  • Do you know what you want to develop?
  • You can solve all possible problems in the development project.

  2. Use pseudocode

Pseudo-code is a very good way to show you how long the program is to be written?

Some people do not like pseudocode because they do not want to write the same code twice, namely, pseudo code or real code. In fact, this is understandable, because the two copy items are not easy to maintain. However, I think this can be weighed. If the algorithm is very simple, you do not need pseudo-code. If your algorithm is complex and round-robin, it would be nice to have a pseudo-code outline, because it helps others understand a complex algorithm or system from a simple document. This is like a wiring diagram of a wire. You can easily find clues from complicated implementations through a simple document.

  3. Write clear comments

Please write clear program comments in your code. Of course, the more comments, the better. The comments should be concise. If your program is clear and simple enough, the comments will be redundant. In addition, the comment should be "reason, reason, and purpose", rather than "what is ".

  4. Use an automatic editing tool

There are many automatic editing tools, such as typinator, which can be used to quickly insert duplicate statements by setting some alternative simple code, such as your own signature and common statements, it allows you to set alternative short code. There are other tools that automatically complete code, such as some VC plug-ins, and something like source insight. Don't underestimate the time. If you write code every day, today and tomorrow will save you a lot of time.

  5. Reduce code

Reduce the number of codes and stick to the dry (don't repeat yourself) and kiss (keep it simple & stupid) principles. In this way, there can be transactions to reduce the complexity of the Code, improve the ease of coding and maintainability of the program, and also increase the quality of the Code.

  6. code reuse

The dry (don't repeat yourself) principle tells us that we need to reuse the existing code. In this way, you can stand on the shoulders of giants, so that you can pay more attention to the business logic you want to deal. The highest level of programming is that the written code may be reused. Reuse and generics are the goals that are always pursued in programming.

  7. Code Reconstruction

Some old code may be out of date. Compared with the old c ++ STL library, there may be many problems under multithreading. Therefore, our own code is the same. Every time, we need to recycle and reuse the code, which is the reconstruction of the software. The pursuit of refactoring code is not to provide more functions, but to make the old code more active, so that the old code can keep up with the times, more scalability and flexibility.

  8. Use the design mode

The design pattern is a methodology for solving some problems at the code level. There are many design patterns in the world, such as MVC, single instance, factory, observer, and so on. A good design pattern can make your code more reusable and scalable.

  9. Use the program framework

Frameworks is a gift for programmers. They have helped you complete many details. They may be a lib library. You need to perform simple assembly, an almost completed software framework has been formed. This is something that can speed up development. As long as you search the Internet, you can see too many frameworks. Almost all contribute from open-source communities.

  10. Generic programming

If something similar in a program is drawn and these similar things are implemented with a standard things, this is also one of the highest realms pursued by programming, something like STL in C ++ is the best embodiment of this kind of thing. Flexibility makes it almost universally accessible.

  11. Use open-source code

There are too many open source code in this world. Learning to use them can save you time and energy, because we don't have to implement a lot of things several times. Learning to use open source code is not just a learning process, it is also a matter of increasing programming efficiency.

  12. Improve the development environment

The development environment is very important, because a good development environment can give you half the effort. They don't need to pay attention to anything else. For example, I have seen a programmer spend a lot of time adjusting the font and highlight of the editor. Yes, it is worth noting that only by making the development environment comfortable can we make ourselves better programming.

  13. Use the debugger

Learn to use the debugger to debug code, single-step tracking, variable value tracking, memory, stack, and so on. Skillful Use of the debugger allows you to better find program problems and get the best code.

  14. Use version management tools

Version management tools should be something that any programmer should learn to use, especially in a team, how to manage different versions of programs, how to maintain and store code, version management tools are indispensable in the development process. It makes code backup and sharing easier.

14 suggestions for efficient programming for programmers

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.