ISBN: 0-387-94889-9Return to Roman Press Home Page
To order this book through Amazon.com, please click here
This book is about object-oriented programming and how it is implemented in Microsoft Visual Basic. Accordingly, the book has two separate, though related, goals: to describe the general concepts of object orientation and to describe how to do object-oriented programming in Visual Basic.
Readers are assumed to have only a modest familiarity with Visual Basic and some rudimentary programming skills. On this foundation, the book introduces the abstract concepts of object orientation, including classes, abstraction, encapsulation, and object creation and destruction, showing how each is implemented in Visual Basic.
The style of the book is hands-on, with plenty of code examples for the reader to try. The book contains complete chapters on handling object errors and OLE automation objects. Visual Basic programmers and students will find this an invaluable introduction to the topic.
This book is about object-oriented programming and how it is implemented in Microsoft Visual Basic. Accordingly, the book has two separate, but intertwined, goals. The first is to describe the general concepts of object orientation and the second is to describe how to do object-oriented programming in Visual Basic. I intend this to be a short, no-nonsense book that can be read through once and then easily referred to at later times. (Long stories about a mythical company and its programming problems are seldom interesting the first time through, let alone the second, third or fourth times!)
To read this book, you need only a minimal acquaintance with Visual Basic. In particular, I assume you can construct a simple Visual Basic program and have some rudimentary knowledge of fundamental programming techniques. This book does not teach Visual Basic - it teaches you how to program Visual Basic in an object-oriented way. The issue here is not how much Visual Basic you already know - it is that you want to learn about object-oriented programming techniques.
With regard to the first goal of the book, it is my feeling that a discussion of the underlying concepts of object orientation (just what is an object, a class, encapsulation, abstraction, and so on) is essential in order to take full advantage of any object-oriented language. Simply put, it will help you understand what you are doing if you know why you are doing it.
Let me put this issue in perspective with my own experience. I had been programming in earlier versions of Visual Basic for some time when I plunged into Visual Basic 4.0. As I usually do with a new application, or new version of an old application, I began by reading the documentation, turning to other books only when I felt that I needed some clarification - although this was seldom helpful. After spending a good deal of time poring over the manuals, I concluded that I could now follow the syntax and create an object-oriented program in Visual Basic. However, I was left with some very annoying questions, such as
My only recourse for answering these questions was to dive into some more academic treatises on object orientation (which I enjoy doing). After consulting several books, I began to see some light. It felt as though a curtain had been raised, and I finally began to understand the raison d'être of object orientation - if not all of its subtleties.
I can't resist the temptation to share with you one example of the frustrations associated with trying to learn the basic issues of object orientation. Here is a quote from an excellent book (really) on the subject:
The class Class is a subclass of the class Object; and thus, the object
Class points to the object Object as its superclass. On the other hand, the
object Object is an instance of the class Class; and thus, Object points back to
Class. Class Class is itself a class, and thus an instance of itself.
To be entirely fair, this is not as confusing as it looks when taken out of context. But it does illustrate some of the difficulties in learning about object orientation. I wrote this book to help the reader get some insight into object-oriented programming without having to suffer through such frustrations.
I should also hasten to add, lest you think this book might be too academic, that this is definitely a book about Visual Basic. Thus, we will not dwell on abstract concepts in great depth, nor will we spend much time on aspects of object orientation that do not apply to Visual Basic.
The second goal of this book probably needs less motivation than the first, since I would guess that most people are more interested in how than in why. In any case, a concrete context helps clarify the abstract notions and provides a starting place for building object-oriented applications. As the title of the book suggests, we will use Visual Basic (version 4.0 or later) for this context.
Let me say a few words about my writing style: I will try to use only as many words as necessary in explaining the concepts and as few words as possible in dealing with the examples.
With regard to the examples, I find that I can learn much more quickly and easily by tinkering with and tracing through short program segments than by studying a long, detailed example. The difficulty in tinkering with a long program is that changing a few lines can affect other, perhaps irrelevant, portions of the code, to the point where the program will no longer run. Instead of wasting time trying to figure out why it will not run, I usually just give up.
On the other hand, if, for example, I want to experiment with how to break a circular reference in Visual Basic, I write a short program, of perhaps one or two dozen lines, with which to experiment. This is a great way to learn and also shows off the advantages of an interpreted language. I often save these little code snippets, for future tinkering. Accordingly, this book is filled with short code snippets. I encourage you to key them in and experiment with them yourselves.
Many books on object-oriented programming devote a great deal of space to program design issues, which are certainly important, especially for large projects involving lots of programmers. I shall leave this topic for others to write about.
The complete source code for the Turing Machine application (in Chapter 3) should be available on the Springer-Verlag Web site, under http://www.springer-ny.com/supplements/sroman
Thanks for looking at my book. I hope you enjoy it.
1. The Basics of Object-Oriented Programming Data Types Encapsulation Abstract Data Types Classes Objects The Object/Message Model The Me Keyword Object Properties and Object Hierarchies Creating and Destroying Objects Form Modules Collection Classes Polymorphism and Overloading Inheritance 2. Handling Error Objects Error Detection and Error Handling Types of Errors The Error Object Dealing with Run-Time Errors Dealing with Logical Errors Handling the Error in the Calling Procedure Errors Occurring in Events An Error-Handling Example 3. Turning Machines -- A Simple Obejct-Oriented Example What Is an Algorithm? What Is a Turing Machine? Coding a Turing Machine 4. OLE Automation Objects What Is OLE Automation? The Plan for This Chapter Communication Between OLE Automation Clients and Servers Creating a Simple OLE Automation Server Referencing the Server's Type Library Registering and Unregistering a Server How Servers Are Started and Ended Reference Counts for Servers Servers with a Visual Interface Handling Errors Externally Creatable and Dependent Objects - The Object Hierarchy In-Process Issues Version Compatibility
To order this book through Amazon.com, please click
Return to Roman Press Home Page
Return to computer books' main page