No matter what craft you're practicing, two things are very essential for making progress with that craft and getting better at it, wiz. Theory and Practice.
Its quite obvious why practice should come after theory, because you can't do something without knowing how to do it. If you try doing it, you won't be having any idea of what you're doing(which makes no sense).
So here is a list of things that'll guide you through 'Ideal way of learning a programming language'.
Theory:
1. Read
Reading about the language you're about to learn is the best way of starting off. Three kinds of books are enough for reading,
(optional) - Introductory Book (that introduces the language)
(mandatory) - Reference Book (that elaborates the language)
(optional) - Specialization Books (that specializes a specific part of a language)
You must be thinking how boring it sounds to just read read and read, well you're right. Reading (theory) can be boring at time. If you feel like you're getting bored of reading theory or not getting anything; stop! Skip over to 2nd point.
Reading is a passive thing for some people, and for some its active. But the majority of people think of it as just sitting and scanning symbols that may or may not make any sense at all. Well everyone has a right to propose their opinion, and I think reading can be made active. (by taking notes, drawing up imaginary figures that pop up in your mind when you're reading, etc.).
2. Read the example code
Reading the example code and trying to figure out what its doing is the most effective way of learning any programming language. Once you get to know about the language while reading, you can skip to reading example code whenever you get bored of reading theory.
If you can't figure out what the code is doing, don't worry just skip over to next point.
Practice:
3. Type that example code yourself and run it.
As you type the code yourself into the editor, you'll start getting a hint of whats going on in the program. The best practice is to add your own comments while rewriting code. As to to explain WHY something is done. People have been taught to comment their code to explain whats being done. Well according to me, thats not really an important thing to comment about. As the program itself should be well written enough to give you an idea of whats going on. Instead the best commenting would be about WHY something is being done.
For example:
int calSquareArea(int side)
{
return side*side; // returning square of 'side' <-- isn't it obvious!? dumb-ass!
}
int calSquareArea(int side)
{
return side*side; // formula to calculate area of square is side*side <-- Ooh! I didn't know that.
}
4. Change it.
Now that you know what the nuts and bolts of example code is, you can tweak it a bit and run again. As the program works differently each time you tweak and run it, you can make it to whatever you want. Its quite an useful skill to modify already existing code and make it do whatever it is that you want to do.
5. Write your own code.
Writing your own code is like making your own world with your own terms. You're the God of that world, you get to decide what happens in it. Sounds awesome, doesn't it? So where to start?
Basically, there are two well known approaches to start building an application, namely top-down approach and bottom-up approach. In top-down approach you start with very high level abstract of your program, with undefined methods and a few variables. Where you know what the methods are going to do, but you haven't really defined them yet. Another approach is to start writing a part of program you have in your mind. You can do the same with other parts, and at the end you can integrate them all together as a whole system.
I always like to start with variables or attributes, because once you've got your variables, you can think how to work on them i.e. writing functions or methods that will be using those variables. And I define methods as I go on, thus increasing complexity as I go on.
*Note: This is not scientifically proven best way to learn programming language, but I think its ideal because it did prove best for me. You might be comfortable with another way which I'm not aware of, but you're always welcome to give it a shot.
0 comments:
Post a Comment