Chapter 6. Inheritance: Getting a Lot for a Little


When I was just starting out in the computer industry, I learned a very important concept from a wise and experienced college professor. He told me that successful programmers are selectively lazy. When I became a college professor, I taught the same concept a bit differently; I used to teach my students how to be successfully lazy. Indeed, laziness in programming, when properly used, can be a virtue.

How can laziness help programmers? If you ever decide to take a job as a game programmer, you'll find that there are two kinds of programmers. The first is incredibly hard working. When given the assignment to write a new game or a part of a game, he immediately sits down at his computer and starts coding. He works long, long hours and is extremely dedicated. Unfortunately, he doesn't have much of a life.

On the other hand, a successfully lazy (and smart) programmer approaches a new assignment a bit differently. She looks around for code she can reuse or repurpose. She searches for code on the Internet, in books and magazines, and in commercial code libraries. As she does, she usually finds that she can reuse or repurpose code for about 50%80% of her task. This saves her a tremendous amount of effort and enables her to finish much more quickly than the hard-working (but not quite so smart) programmer. She has then time to concentrate her creativity on the most important parts of the game so that she can make a more innovative and unique game.

In programming, reusing code, or being successfully lazy, is a subject called inheritance, which we'll discuss in this chapter. The most important reason for studying and using inheritance can be summed up with the old saying, "Work smarter, not harder." Inheritance helps us do just that.



Creating Games in C++(c) A Step-by-Step Guide
Creating Games in C++: A Step-by-Step Guide
ISBN: 0735714347
EAN: 2147483647
Year: N/A
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net