An Object Lesson

An Object Lesson

When I started to learn object-oriented programming about 10 years ago, I found its concepts somewhat difficult. I read every book I could get my hands on and thought about all that I'd read, but it still didn't make sense. I performed due diligence and put in the time, but for some reason OOP didn't click. "What's this business about creating a class and calling methods? After all, didn't I do the same thing with C math libraries for years?"

Then one day I had a revelation! All at once I realized how simple the concepts of object-oriented programming really are, and I became a believer. I spent time reflecting on why I took so long to understand a concept that turned out to be so simple and realized that the reason was twofold. First, the authors of the books I read seemed to obfuscate OOP by using terms such as overloading, encapsulation, inheritance, and polymorphism all over the place before they were clearly defined (at least for me). While I might have muddled my way through this terminological maze, the knockout punch was the examples the authors provided, which were contrived and never about anything that could be used by a programmer to solve real problems. Although I tried to match alien concepts with contrived and overly difficult examples (again, at least to me), OOP didn't sink in. I had pictures of cookie cutters, stars, and rectangles dancing in my head. These images were the hands-down favorites of every author discussing object-oriented programming. To me, they hadn't made any sense.

To save you the time I spent scratching my head and thinking about objects until my brain hurt, I'll use prefabricated objects such as a Windows form and a few control objects to illustrate object-oriented concepts. By working with something that you already use in your programming, the jump to thinking about objects is much, much easier. Over time, I've found this approach to be the clearest way to illustrate the principles of OOP.

I'll cover objects and classes, properties, methods, inheritance, overloading, polymorphism, and sharing, all within the context of what you know. In Chapter 3, "Writing Your First Class" when you start to write your own classes, you'll fully understand the concepts and you'll be able to concentrate on the code.



Coding Techniques for Microsoft Visual Basic. NET
Coding Techniques for Microsoft Visual Basic .NET
ISBN: 0735612544
EAN: 2147483647
Year: 2002
Pages: 123
Authors: John Connell

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