Foreword: believe that each self-taught programming person, the way of getting started has experienced a lot of bumpy. But we have a lot of "good teachers" around us, so we can always bring surprises to use. The use of "search" is one of them.
This article selected from the "Road programming", how to solve the problem of self-study programming through search.
If you're doing a JavaScript project where you get a string format date (for example, ' 2014-10-08 '), you want to calculate what the next day's date is. We can use parseint to convert a string into text, so you use this function.
function nextDay(str) { var num = parseInt(str); return num + 1; } var date = ‘2014-10-08‘; var dateParts = date.split(‘-‘); alert(nextDay(dateParts[1]));
Everything went well. Then one day you realize that your program has produced some very strange results, but only in the old version of Internet Explorer: Your program thinks ' 2014-10-08 ' the next day is ' 2014-10-01 ' instead of ' 2014-10-09 '. You set some breakpoints and step through the code, you will find that parseint looks bad: When the parameter is ' 08 ', you will get 8 in most browsers, but in IE you will get 0. You have found this problem, but you do not know how to fix it. What are you going to do now? As you continue to program, you will continue to encounter similar scenarios. More frustrating than the dilemma is not knowing how to get out of trouble.
parseint Explanation
Why does the old version of IE's parseint do such strange things? The reason is that parseint is also valid for numbers other than decimal (such as binary, octal, and hexadecimal). If you don't tell parseint what you're using, parseint uses it as a reasonable way to parse the numbers, and ' 08 ' looks like a 8-digit binary number. The new browser tends to use 10 binary by default, even though the string starts with 0, but the old version of IE still thinks ' 08 ' is a 8 binary. In any case, you should always specify the binary when using parseint: parseint (' 08 ', 10); (10-based, or decimal) will return 8 in all browsers. In the Google era, everyone is a search expert. In less than a few seconds, you can find all sorts of information, such as the gossip about the movie actress you're watching. Because the internet was and is now built by programmers, the Internet on the programming information is particularly much. When you encounter a problem like the one in front of parseint, you will definitely find the answer as long as you know where to look and how to find it.
Find the RIGHT keyword
If you don't know what to search for, you won't be able to find the results. I encountered this problem the first time I wanted to use an escape character. I don't know what kind of thing is called an escape character. All I know is that the apostrophe is destroying my string. In the parseint example, you may not know where the problem is, so how do you search for a solution? The key is to find the right search keyword. If you're looking for something specific to a programming language, include the name of the programming language in your search. Then imagine how other people who met the same problem would describe the problem. For example, when searching for the results of a parseint problem, a good query might be "JavaScript parseint returns 0". When I run this search, the first record returns the answer I'm looking for.
If you're not sure what to search for, Google's search suggestions can help you. When you enter the beginning of the query, the hint can help guide you through the search keywords that can be used to find the best results. These suggestions mean that someone else has searched these keywords and got a good result, so you might be able to succeed. Shows some useful (and some less useful) suggestions when searching for parseint solutions.
Upgrade
The resources you are looking for depend on which level of learning you are in. For example, if you are thinking about learning to write a python program, you want to find introductory information about the benefits of Python. In this example, you would want to use search keywords such as "Why Use Python" (for why Python) and "Python features" (Python features). After you decide that Python is right for you, you will want to learn the basics of Python. At this point, you will search for something like "python tutorial" (Python tutorial). After you've been working with Python for a while, you may encounter a problem that requires regular expressions to be used. You already know what a regular expression is and when to use it; you just need to know how to use it in Python. Then you might search for "python regular expression" (Python regex) or "Python Regular expression Documentation" (Python regular expression document) to find out about A document description of how the expression works in Python. Now assume that the document is abstract and difficult to understand; You can search for "python Regular expression Tutorial" (Python regular expression tutorial) or "Python Regular expression Example" (Python regular Expression example) to find some more easily digestible Python regular expression information. These examples show that if you specify at what level you are in the search keyword, you will be more likely to find the information you need.
Error
Errors can be particularly disturbing because your code doesn't work, and the error message looks particularly blurry. But the error message has one advantage: the text in the error message is basically constant. This means that other people have seen the same error message and are likely to have found a solution. When you encounter an error message that you do not understand, copy and paste the entire information to Google, you will generally find the answer to the question.
The beginning of the end
In the beginning, you may not know exactly what you are searching for. You may not fully understand the problem to be solved, or even do not know how much you need to learn to solve it. Just because you're not entirely sure what you're looking for, doesn't mean you can't search for it. The beginning of the end, the origin. First, search for your final goal, and in the process of your search results, pay attention to unfamiliar words and phrases, then search all of these seemingly relevant keywords and record all unfamiliar words and phrases in the results again.
When you reach a point where you can understand almost anything in the search results, you can start learning things that you don't understand until you reach a point where you know enough to build what you were supposed to build. This process will help you learn a lot of great knowledge in the process of achieving your goals, or at least help you realize that your goals may require more work and learning than you expect.
This type of search led me to learn web programming. I mentioned earlier that the first site I had was "auto-complete". I didn't know it was auto-complete, so I searched for something like "Google search suggestion", which made me find the keyword "autocomplete". I read some articles about AutoComplete, making sure that was what I was looking for and found the keyword AJAX. I learned that Ajax is the technology that implements search recommendations based on user input. I did some Ajax research and found that you had to write JavaScript to use Ajax. So I started to learn JavaScript, and until I learned enough knowledge to use AJAX, I could build an auto-complete system. In this process, I learned a lot about HTTP, Web servers, and data structures. I believe that solving programming problems in a way that is traceable will give you a lot of rewards.
Identify high-quality resources
Unfortunately, not everything on the Internet is very high quality. This is true of programming information and everything else. Beware of websites and books that are not of high quality. Because I believe in the outdated, poorly written information on the website, I learned a lot of wrong guidance and bad habits. Unfortunately, you may have to take a few losses before you can differentiate between high and low quality resources. If the websites you visit have a lot of ads, especially if they don't have anything to do with programming, then you need to be careful. Beware of websites that try to include various topics (for example, about.com includes tax returns, gardening, programming, and hairstyle design). When you see a simple statement that says what you want to learn, be careful, if it's too simple, you'll probably learn the wrong way. Most programming languages, libraries, and frameworks have Web sites that contain complete, high-quality documentation. These sites generally contain complete introductory information, beginner guides, tutorials, and reference materials. The information found on these sites is usually of a high quality and correct.
Personal blog: Hidden Treasures
Although you have to be careful about the information you get from an unofficial website, you can still find some valuable information on your blog. Professional programmers like to write out the problems they've solved, usually in a blog post. The documentation and tutorials are great, but nothing compares to the real-world problem and its solution. But before you believe this information, you still have to investigate the author. Check out their LinkedIn resumes, stackoverflow files, github files, and any other resources you can find. If they seem to understand what they're saying, you'll find a good source of information. Such blogs are like programming mentors; they give you free advice on how to program better. Remember, if you receive their advice, you should mention that blog in the documentation.
This article is selected from the "Road Programming", click this link can be viewed in the blog point of view website.
Using "search" to solve the problems of self-learning programming