`
Rowen
  • 浏览: 83191 次
  • 性别: Icon_minigender_1
  • 来自: 福州
社区版块
存档分类
最新评论

5 Ways You can Learn Programming Faster

阅读更多
5 Ways You can Learn Programming Faster
by Alex Allain
http://www.cprogramming.com/how_to_learn_to_program.html
Learning to program isn't something you can do in an afternoon, but it doesn't have to be a life's work, either. There are lots of things you can do to make it easier on yourself when you are learning to program. You already know about The 5 Most Common Problems New Programmers Face--And How You Can Solve Them. Now, discover how to get the most out of your learning.

One common theme across many of these tips is:

don't go too fast; get it right before moving on.

When I was teaching C, there were always a few students who came into the class knowing a bit about programming. Inevitably, some of these students did great in the first few weeks only to fall further and further behind as the course went on. Why? They went too fast through the introductory part of the course, thinking they knew it all--but they rarely did. They knew some of the material, but not enough to have a strong grasp of the fundamentals.
At the same time, you must not stop making progress--you can go too slow as well as too fast. Don't avoid a topic after you've mastered everything leading up to it. By facing more challenging ideas, you'll help cement your grasp of the basics.

1. Look at the Example Code

Reading is usually about the words on the page, but learning to program is about code. When you're first learning to program, you should make sure to look at, and try to understand, every example. When I first learned to program, I would sometimes read the code examples before the text, and try to figure out what they did. It doesn't always work, but it did force me to look at the example very carefully, and it often helped make the writeups clearer.

If you want to see what sample code looks like, you can read this site's introductory programming tutorial. This tutorial spends a great deal of time talking about the sample code to help you work through exactly what the code does.
2. Don't Just Read Example Code--Run It

But when you're reading a programming tutorial (or book), it's easy to look at the sample code and say "I get it, I get it, that makes sense". Of course, you might get it, but you might not get it, and you just don't know it. There's only one way to find out--do something with that code.
If you haven't already, get a compiler like Code::Blocks set up.
Then type the sample code into a compiler--if you type it, instead of copying and pasting it, you will really force yourself to go through everything that is there. Typing the code will force you to pay attention to the details of the syntax of the language--things like those funny semicolons that seem to go after every line.

Then compile it and run it. Make sure it does what you think it does.

Then change it. Software is the most easily changed machinery on the planet. You can experiment easily, try new things, see what happens; the changes will happen almost immediately, and there is no risk of death or mayhem. The easiest way to learn new language features is to take some code that works one way, and change it.
3. Write your Own Code as Soon as Possible

Once you understand something about the language--or even if you're still getting your head around it--start writing sample programs that use it. Sometimes it's hard to find good ideas for what programs to write. That's OK, you don't have to come up with every idea at the beginning.

You can find some programming challenges on this site.

You can also reimplement the examples from the book or tutorial you are reading. Try to do so without looking back at the sample code; it won't be as easy as it seems. This technique can work especially well if you tweak the sample code.

If you can't think of a small program to write, but you have in mind a larger program you want to implement, like a game, you could start building small pieces that you can later use for a game. Whether you use them later or not, you will get the same useful experience.
4. Learn to Use a Debugger

I already talked about the importance of debugging in The 5 Most Common Problems New Programmers Face--And How You Can Solve Them. But it bears repeating; the sooner you learn good debugging techniques, easier it will be to learn to program.

The first step in doing so is to learn how to use a tool called a debugger, which allows you to step through your code.

A debugger will allow you to step line by line through a piece of code. It will let you see the values of variables, and whether the code inside an if statement is executed.

A debugger can help you quickly answer questions about what your code is doing.
int main()
{
        int x;
        int y;
        if( x > 4 )  // <-- what is the value of x here?
        {
                y = 5;   // <-- did this line of code execute?
        }
}

A final word about debuggers: the first time you learn about a debugger, it will take you longer to fix the problems with your code. After the tenth or so bug, it will really start to pay off. And believe me, you will have way more than ten bugs in your programming career.

I often saw students unwilling to use a debugger. These students really made life hard on themselves, taking ages to find very simple bugs. The sooner you learn to use a debugger, the sooner it will pay off.
5. Seek out More Sources

If you don't understand something, there's a good possiblity the way it was explained just didn't click.

First, look for alternative explanations. The internet is filled with information about programming, and some explanations work better for different people; you might need pictures, someone else might not. There are also lots of good books with detailed explanations.

But if that doesn't work, the easiest way to figure out where your misunderstanding lies is to ask someone else. But try to go beyond saying, "I don't understand. Please explain." You're likely to get a link back to the same text you didn't understand. Instead, rephrase your understanding of the text in your words. The more your question reveals about what you are thinking, the easier it will be for a knowledgeable expert to answer it. Programmers sometimes have a reputation for being grumpy about answering questions, but I think the reason is that they want to make progress in a conversation, and that requires both sides to put in effort. If you ask a smart, detailed question that shows you are thinking, you will generally get good results.

There are plenty of places you can go to ask questions. You can always email me, or post on our message board, or ask an expert.

In the coming days, I'll be writing more about how to learn to program effectively. Stay tuned, by subscribing to our RSS feed, signing up for email notifications, or following @alexallain on twitter.
分享到:
评论

相关推荐

    Learn.Cplusplus.In.A.DAY.1519318588.epub

    ) I made this crash course to show you HOW you can learn C++ FASTER than you ever thought possible. I will teach YOU step by step the C++ Language extremely quickly. I will TAKE you through a step by ...

    《Hands-On GUI Programming with C++ and Qt5》---Author: Lee Zhi Eng .epub格式+code

    In the initial part of the book, you will learn what Qt 5 is and what you can do with it. You will explore the Qt Designer, discover the different types of widgets generally used in Qt 5, and then ...

    Learn CSS In A DAY

    I made this crash course to show you HOW you can learn CSS FASTER than you ever thought possible. I will teach YOU step by step CSS extremely quickly. I will TAKE you through a step by step guide ...

    A Smarter Way to Learn Python Learn it faster. Remember it longer

    ### A Smarter Way to Learn Python:Learn It Faster. Remember It Longer. #### 学习方法介绍 这本书《A Smarter Way to Learn Python》旨在帮助读者更快速地学习Python,并且能够长时间记住所学内容。作者马克...

    Learn C++ Programming Language C++11 书签修正版pdf

    Learn C++ Programming Language: Become A Complete C++ Programmer 原书是mobi格式,这个是mobi转成的pdf(没有书签),本人添加了书签进行修正-by yinkaisheng English | 2015-10-01 | ASIN: B0162QA2GC | 1 ...

    Learning C++ Functional Programming

    By the end of the book, you will be familiar with the functional approach of programming and will be able to use these techniques on a daily basis. What you will learn Get to know the difference ...

    Hands-On Game Development with WebAssembly Learn WebAssembly C++.epub

    You will learn how to build a WebAssembly application using C++, Emscripten, JavaScript, WebGL, SDL, and HTML5. This book covers a lot of ground in both game development and web application ...

    Java.Crash.Course.1541019245.epub

    We are absolutely sure will love all our 21 lessons, and we sincerely hope they help you learn and improve Java programming language much, much faster. How Will You Java Skills Improve? You will ...

    Python.Crash.Course.15196386.epub

    Are You Ready to Learn Python Programming FASTER Than You Ever Thought Possible? Welcome to the Ultimate Crash Course on Python! Are you ready to unlock the keys to the future? If your answer is a ...

    Beginning Python(Apress,3ed,2017)

    Ten accompanying projects will ensure you can get your hands dirty in no time. Updated to reflect the latest in Python programming paradigms and several of the most crucial features found in Python ...

    Java 9 Programming By Example

    Our example-based approach will get you started quickly with software programming, get you up-to-speed with Java 9, and improve your Java skills This book will show you the best practices of Java ...

    Python Network Programming Cookbook, 2nd Edition 2017 pdf 5分

    You will learn about the concepts and fundamentals of SDN and then extend your network with Mininet. Next, you'll find recipes on Authentication, Authorization, and Accounting and other alternative ...

    Mastering The Faster Web with PHP, MySQL, and JavaScript 1st pdf

    After reading this book, you will know how to boost the performance of any Web application and make it part of what has come to be known as the Faster Web. What you will learn Install, confgure, and...

    Git Version Control Cookbook 无水印pdf 0分

    As you progress through this book, you will learn how you can automate the usual Git processes by utilizing the hook system built into Git. The book also covers advanced repository management, ...

    QGIS Python Programming Cookbook - Second Edition

    You will also learn to create, edit, and optimize a vector layer for faster queries, reproject a vector layer, reduce the number of vertices in a vector layer without losing critical data, and ...

    QGIS Python Programming Cookbook

    You will also learn to create, edit, and optimize a vector layer for faster queries, reproject a vector layer, reduce the number of vertices in a vector layer without losing critical data, and ...

Global site tag (gtag.js) - Google Analytics