2011年12月21日 星期三

Preface


These notes are not intended to be a textbook. These pages represent numerous revisions of examples and notes of C++ concepts that I used for myself to gain an understanding of the language over the last dozen, or so, years. Since I learn best by looking at examples, I decided long ago to use these notes as a teaching tool. Every time I teach a class in C++ using these notes, I find mistakes, shortcomings, inaccuracies, and explanations needed. I make a list of corrections and notes to myself to rewrite this or that. And, even though I update the notes almost every time I teach the class, I never get it right. I do believe, however, that this makes me a better teacher – not being satisfied. I think that if I ever got it right, I'd have to quit (by then the language would be totally obsolete).

To make effective use of these notes, you have to learn to read examples. Reading an example of code, is not like reading anything else. It's like, you read a line of code, then you ask yourself:
  • What does this mean?
  • Why did the author do it this way?
  • What's that function?
  • What does that syntax mean?  Who's doing what to whom?
  • Is there another way of doing this?

Step back …

What's the point? (do I understand the concept(s) that Joe is trying to demonstrate)
This is a time-consuming and tedious process. (I can't read very much of someone else's code without getting antsy and distracted). As you become more experienced, you will be able to skip over "obvious" lines of code and concentrate on the gist of the example. (After you've seen #include <iostream> dozens of times, you won't even think about it). To be successful in reading examples, I recommend that you don't try to spend a lot of time doing it. Reading one or two examples and really getting it is better than trying to read six or ten examples and "kinda", "sorta", getting it.

Reading an example and getting it means that you "own the code". It's yours now. It doesn't mean memorizing it. It doesn't even mean that you don't have to look back see how to do that. It means that you understand how it works and you can reproduce, when needed, the concept or the logic (and take another look if you need to). After all, when you're cooking lasagna, you may have made it dozens of times, but it doesn't hurt to have the recipe next to you when you are making it for the fifty-first time.

針對每一行程式問自己:
  • 這是甚麼意思?
  • 作者為甚麼要這樣寫?
  • 這個 function 是甚麼?
  • 這個 syntax 是甚麼意思?
  • 有其他的方法可以達到一樣的目的嗎?

1 則留言:

  1. Everything looks good in your posting.
    That will be necessary for all. Thanks for your posting.

    Dodge Grand Caravan AC Compressor

    回覆刪除