11 tips to improve programming skills

Source: Internet
Author: User
Keywords We if variables
Tags aliyun clear code demand example help how to how to solve

This article is HTML5tricks original translation, reproduced, please read the end of the article reproduced, thank you for your cooperation!

Do not talk nonsense, directly on the steps.

1. First carefully http://www.aliyun.com/zixun/aggregation/11009.html "> Analyze the problem

2. Then think about how to solve this problem

3. Collect all the needs.

Take the time to write down what the final product will accomplish and identify which of our target audiences are. If this step can be done, it will save a lot of time for the back, is the so-called sharpening cut firewood workers.

Write a comprehensive implementation plan (or model).

If it is a small project, this step may come out just a basic process or a simple equation.

If you are a larger project, this step helps us to cut it into several modules, and then think the following questions:

What tasks do each module need to perform?

How to pass data between modules

How to call the data in the module

Although it is tedious and boring to collect and plan requirements rather than go straight to writing code, but if this is not done, the debugging behind will be particularly tedious. If we could take the time to devise a proper program flow and structure, we would have actually half done it before we wrote the first line of code.

5. Comment our code.

If you think your code may need to be explained, then comment it. Each function should be described in advance a row or two of its parameters and return the results. What annotation should say is why compared to what you are telling you Also remember to update the comments when the code is updated.

6. Define variables using a uniform naming convention.

This will help us to keep track of each type of variable and at a glance what each variable will look like. The benefits of this one is not just for the convenience of us to call X = A + B * C so simple, it will make our code easier to debug and maintain. One popular nomenclature nowadays is the Hungarian nomenclature, which uses the type prefix in variables. For example, for the overall variable, we can use intRowCounter, the string is strUserName. It does not matter what your naming rules are, as long as you stay consistent and can easily describe variables.

7. Formatted edit code, code structure visualization.

For example, encounter conditional statements (if, else, etc.) and loop statements (for, while, etc.) indentation code. Also, you can include a space between the variable name and the operator symbol, which means "+", "-", "*", "/" and "=" (for example, myVariable = 2 + 2). This not only makes your code more intuitive and elegant, but also makes our program flow more clear.

8. Comprehensive test.

First, test whether each module works independently by entering the values ​​we expect. Then try to enter some possible but rare values ​​to continue the test. This basically exposes all the hidden bugs. Test also has the so-called skills, through practice and practice, we can gradually build up their own skills. The test should include the following:

Extreme values: positive values ​​with 0 and greater than expected maximum; empty string for text, null parameter.

Meaningless value. Although it is unlikely that users will type in garbled characters, it's good that we test it ourselves anyway.

Incorrect value. Enter 0 in the division or a negative number if the expectation is positive and the square root of the square root. When the input type is a string, enter a non-number and see if it will be resolved to a numeric value.

Practice, practice, or practice.

Programming will also continue to advance with the times. So there's always something new we need to learn about - and even more useful and important - and of course there are always things that we can not help but think about.

10. Reduce the risk of changes in demand.

In the real work environment, demand is always changing. However, if we had a very comprehensive collection of needs in the early stages and the initial implementation plan was very specific, the likelihood of a late plan due to a change in demand and a misunderstanding between the two parties would be much lower.

We can improve the clarity of the process by showing requirements documents and implementation plans before we start writing code. This will help to ensure that our program is actually done on the client's request.

If you compare a project to a series of milestones, you just need to finish one at a time. Remember, the less things to think about at any given moment, the more detailed and perfect we can think of.

11. From easy to difficult, from simple to complex.

If your software is complex then I suggest you start with a simple module. For example, there is a project where you design a program that requires a gradient graphic that follows the direction of the mouse and changes shape based on the mouse speed.

First, design a square, write a code that will allow it to follow the mouse, and then remove the motion tracking issue separately. Of course, this is the first step.

Next, correlating the size of the square with the mouse speed solves the problem of shape changing with speed.

Finally, create the actual shape you want and connect the three components together.

Naturally, this method is used to write modular code. And each component has its own independent function. This is very useful for code reuse (for example, you can easily apply the first step in other projects to implement mouse tracking) and make our program easier to debug and maintain.

Translations link: http://news.html5tricks.com/11-tips-improve-coding-skills.html

English Original: How to Improve your Skills as a Programmer

Translation of: IT News - Jiang Lili

Related Article

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.