The five keys to becoming the most cattle programmer

Source: Internet
Author: User
Keywords Programmers notes what

Want to be the most cow programmer? The following points will help you achieve this goal.

Tip 1 to method rather than memory

A programmer friend of mine often tells me how helpful it is to remember that more than 200 C + + functions are available. "I never have to look up the definition of a function, so I can program 50% faster than other programmers." "he said proudly. But what is the result? Didn't he know that the compiler's code completion could save a lot of time finding functions and input functions, and that when C # was released, his efforts on the memory function were in vain. Of course, it is necessary to memorize functions in programming, but you should spend more time learning how to do things, such as creating a database connection, producing an RSS feed, and then focusing on how the code is implemented. Learning the right way to do things is much more important than rote memorization.

Tip 2 Build Your own repository

We all have a set of code that we have to build for one reason or another. I never remember the exact code statement to connect to the database, so I had to spend 10 minutes in the code set to query it every time. To solve this problem, I created a Word document for recording http://www.aliyun.com/zixun/aggregation/17348.html "> Snippets to help me remember and find." One of my colleagues built a bookmark for the record link, and another colleague stored the content in his mail. Whatever your approach is, it's a good habit to make it easy to find files or content. When you build your knowledge base, you will find that it will greatly help you to write code better and faster.

Tip 3 know what to do instead of what to do

Many beginner programmers ask me, "How do I do this, or how do I do that?" "I always tell them," What do you want to do? "After hearing this, they'll stare at me like I'm dating their mom," he said. This is my next point of view, never to learn what you want to do before you know what to do, such as whether a programmer wants to search for a specific word in a text file. Here's how to do this with C #:

the following references:


String filecontent; System.IO.FileStream MyStream = new FileStream ("C:\\aa.txt", FileMode.Open); System.IO.StreamReader Mystreamreader = new StreamReader (mystream); Filecontent = Mystreamreader.readtoend (); Mystreamreader.close (); int idx = Filecontent.indexof ("string"); if (IDX) {return true}

Now I'm giving him the code to do it, but it's more important to understand what you're trying to do. What we want to do in this case is:
1. Open a file
2. Read the contents
3. Close the file
4. Search string
5. If found, output results
Using this method to solve things produces the following results:
1. It makes language irrelevant
2. Focus your energies on what needs to be done
3. Make your code easier to read and effective
Knowing what to do will make your code more purposeful. It is now easy to write this code in C + +, PHP, vb.net, Ruby on rails, because you understand what to do rather than how to do it.

Tip 4 Create a comment style that works for you

Every programmer hates annotations, but in order to write more quality and readable code, we need annotations. The problem is that most programmers are often told how to annotate, some companies want each line of code to have comments, others want to have a note in front of each function, and others to comment before different blocks of code. I do not agree with this mandatory rule, as long as the code is available, readable and valid, the programmer should be able to annotate it in the format of his or her personal preference. For me, commenting on every line will break the rhythm of the code, I prefer to comment on the front of the function, list what I'm going to do next step, and then program the steps that are written in the reference note in the function. This is the right model for me to help me organize my design before I can program, and to keep my pace, so that I don't interrupt programming because I need annotations, and help others read my code. Here is an example of how I annotate:

the following references:


/* 1. Open file*

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.