The book begins by contrasting traditional client/server computing with today's n-tiered architectures (including Microsoft's three-tiered Distributed Internet Architecture [DNA] approach). A general introduction to designing objects with Visual Basic follows in which the author enlists a case study for a video rental database. This includes a presentation of the best of user interface design in VB (including working with TreeView and toolbar controls).
You don't need to know much about TCP/IP to use DCOM, of course, but a section on this popular Internet protocol with the WinSock control provides some background material.
A full introduction to programming databases with ActiveX Data Objects (ADO) becomes incorporated into the video rental database example. After a quick look at ActiveX controls, the book provides an overview of COM, along with the benefits and potential risks of choosing between DCOM's (often perplexing) threading models.
After presenting material on object linking and embedding (OLE) Automation, the book zeroes in on creating DCOM components, data-aware VB objects with transactions and MTS, and real-world deployment issues with DCOM. These chapters provide a state-of-the-art guide to programming with Visual Basic in ways recommended by Microsoft.
Armed with these robust DCOM objects, the book next turns to the Web--first with ASPs and then with VB WebClasses for generating browser-neutral Web pages on the fly. (A final chapter looks at creating Active Documents out of VB forms for use with Internet Explorer.) In all, this practically-minded text provides a useful tour for real-world thin-client computing with VB and DCOM. The book assures that today's VB is all you need to write scalable, Web-centric distributed components and applications for the Microsoft platform. --Richard Dragan
From the Inside Flap
I have since taken quite a liking to Visual Basic, and have used the language in developing corporate applications for many of my customers, often combining it with Visual C++. Its appeal stems from its many interesting attributes. For one, Visual Basic is amazingly easy to use, and is probably responsible for making many new programmers out of folks who were once "just" users. It is quite non-intimidating to approach, yet can end up challenging the most experienced programmer due to its rich feature content. It reminds me of what is printed on the box of MasterMind, a game in which one attempts to guess a color code created by an opponent - "A minute to learn, a lifetime to master."
I thought of Buck again when Andrew Scoppa suggested that I write a book on developing distributed applications with Visual Basic. My affiliation with Andrew's company, UCI Software Training Centers, goes back over 16 years, and my respect for him is immense. As a quality provider of developer training, I take any suggestions Andrew makes quite seriously. Of course, at the time Buck suggested I look into Visual Basic, its features were not quite rich enough to develop distributed applications. But that has changed.
The Evolution of Visual Basic
As a language for developing Windows dialog-based user interfaces, Visual Basic is in its original element. As a teaching language, Visual Basic is ideal for illustrating not only Windows user interface programming concepts, but topics related to modular software development, code reuse, data scope, and even object-oriented design and programming techniques. For testing COM objects developed in C++ and ATL, Visual Basic offers the quickest solution.
The popularity of Visual Basic is no doubt responsible for its evolution from a graphical user interface development tool to an advanced, high-performance application development environment. Its ease of use, data access capabilities, multi-threading conformance, COM compliance, and native code generation capabilities now make it an excellent choice for the rapid development of the server-hosted business components of a distributed application. Having taught Visual Basic to developers for a number of years, I am beginning to see the language finally receive the respect it deserves. With over 20 years of software development experience and a degree in Computer Science, I feel qualified to author a book that treats Visual Basic with the same kind of respect.
About This Book
This is a book for serious developers of distributed applications. While it is, strictly speaking, an intermediate-level book, I expect the reader to be an experienced programmer. The main theme of this book is to get you started with the development of distributed applications using Visual Basic in the quickest way possible. I have provided complete examples of both 2-tier and 3-tier applications - these applications have thousands of lines of Visual Basic code. Complementing these complete applications are dozens of small demos that illustrate one or two important concepts. While instructions for running these demos are included in the chapters that follow, you should check the README.TXT file on the enclosed CD-ROM for additional and last-minute information regarding the use of the demos.
Probably the most unusual thing about this book is that I start with a chapter on deploying multi-tiered distributed applications. This approach has worked well in the classroom when I teach my courseware, and I expect the same results in this book. Since many of the demos used in later chapters depend on the sample applications being installed, it is essential that you read the first chapter and go through the installation procedures.
In Chapter 2, I discuss how to use objects from a Visual Basic application, using the sample video store objects provided with this book. Even if you are familiar with using COM objects in a Visual Basic application, you should read this chapter. The chapter may seem like a "show-and-tell" for an existing application, but it provides good examples of object design and documentation. In Chapter 3, I cover how to develop Win32 user interface applications that use COM objects. In addition to providing more examples of object use, the chapter is an excuse for me to introduce some advanced user interface techniques. In this chapter, you will learn how to use the Windows registry, display a splash screen, use OLE drag-and-drop, and use advanced user interface controls such as the tree view, list view, tab strip, and toolbar controls. My advanced Visual Basic students often ask to see how to use these controls and techniques in their programs.
I consider Chapter 4 to be the "paying your dues" chapter. In earlier days, programmers had to use APIs such as the TCP/IP socket API to develop distributed applications. The Windows platform SDKs and developer tools such as Visual Basic have made the creation of distributed applications much easier. If you are pressed for time, you can skip Chapter 4.
As an essential and fundamental introduction to developing the middle tiers of a distributed application, Chapter 5 is required reading. This chapter introduces ActiveX Data Objects (ADO), showing both their programmatic use and their use through the new ADO Data Control. Additionally, the chapter explains Data Environments and how to create programs that generate reports from a database.
Chapters 6, 7, and 8 are all about objects. First, I cover the use of class modules in Visual Basic, then move to their use in creating ActiveX Components. Finally, the internals of COM, the Component Object Model, are revealed in more detail than the typical Visual Basic developer would probably want - but more is better than less! If you are familiar with using class modules in Visual Basic, you can skip Chapter 6, but since some of the examples in Chapter 7 extend concepts presented in Chapter 6, it may be better to skim it rather than skip it.
In Chapter 9, I provide all you will need to know, and then some, about creating ActiveX Controls in Visual Basic. Although their development and use is, strictly speaking, not required in a distributed application, it is one of the most popular and requested topics of my students. If you wish, you can skip this chapter.
Interesting uses of COM are presented in Chapter 10, which covers automation fundamentals. In this chapter, you'll learn how to develop Visual Basic applications that launch and control other applications. You'll also learn how to add an automation interface to your own applications so that other programs can control yours. It's a short chapter, and one of my favorite topics, so I suggest you read this one.
A fundamental and hands-on introduction to DCOM, the Distributed Component Object Model, is presented in Chapter 11. Reading this chapter and performing the walkthroughs will give you a solid introduction to DCOM, as well as an appreciation for the features provided by Microsoft Transaction Server (MTS). The serious distributed application developer will want to read and understand this chapter.
Based on my experience, I am quite certain that many of you purchased this book for the topic covered in Chapters 12 and 13 - using MTS. For over a year now, I have often entertained myself by seeing the reaction of students when I ask, "How many of you are interested in learning about MTS?" Even people who have never raised their hands in public since the third grade eagerly raise one, if not both arms, often adding a vigorous circular motion. It goes without saying that you'll want to read both of these chapters.
One of the strongest objections to using a distributed approach to software development is the inherent difficulty in maintenance and troubleshooting - "How would you debug that thing?" In Chapter 14, I attempt to show you that it is not that hard to maintain a distributed application. Additionally, I provide information about the often-dreaded binary compatibility features of Visual Basic. This chapter is essential reading for the serious developer.
Entire books have been written on the topic covered in Chapter 15 - creating Internet interfaces using Active Server Pages (ASP). I have purposely kept this chapter light, because I never really bought into the concept of mixing a program (e.g., "script") with graphic content (e.g., HTML). Certainly there are thousands of developers who love this sort of thing, and are capable of creating interesting Web pages while also providing the programming behind them. The chapter goes a bit beyond getting you started, and I would consider it to be required reading, if only because chances are the existing Web applications you now have were implemented as ASP pages.
A far better approach to developing Web applications was introduced in Visual Basic 6.0, and is the subject of Chapter 16 - creating Internet IIS applications. This new approach allows an applications programmer to program applications and a graphics designer to design graphics. I highly recommend reading this chapter thoroughly.
In Chapter 17, I introduce ActiveX Documents, which many Visual Basic developers are likely to find as appealing solutions for intranet development. While their reach is limited, due to browser compatibility, if you don't need broad reach capabilities for your intranet application, ActiveX Documents are at least worth a look.
Wrapping up the book is Chapter 18, in which you will learn how to use the Internet Transfer and Web Browser controls. In this chapter, you will see how to embed browser capabilities directly in your Visual Basic application, and automate file transfers via FTP.
I have quite a list of people to thank for assistance in writing this book. First, I want to thank Buck Trayser of Digital Equipment Corporation for persuading me that learning Visual Basic would be a good thing. I must also thank Cheryl Jacobs and Tony Todd of M&M/Mars, great customers of mine, for asking that I do a course on Visual Basic 3.0. That course turned out to be the start of a total of eight courses I developed covering Visual Basic from its fundamentals to its advanced features.
Certainly this book would not have been possible without the help of Andrew Scoppa and Donna Thayer of UCI Software Training Centers in Stoneham, Massachusetts. As a senior consulting partner with UCI, I have enjoyed working with Andrew and Donna for nearly 16 years. In my opinion, they offer the best developer training anywhere.
Thanks to Dave Libertone, also of UCI, for his help on this book - as a published author himself, he was a great pathfinder for me. Dave provided me with a terrific opportunity to get my feet wet as an author when I wrote a short chapter for his excellent book Windows NT Cluster Server Guidebook, also published by Prentice Hall. In addition to being a great friend, Dave's technical advice is always as good as gold.
Claudio Ghisolfi and Kay Connolly, also of UCI, deserve a great deal of credit for this book as well. I want to especially thank Claudio for his patience and determination in examining the demos and walkthroughs presented in this book. Thanks to the excellent instructors who have used my courseware and provided feedback on errors, omissions, and suggestions, especially Karen Gallagher and Andy Macentee.
Thanks also to Art Kane and Olivia Kane of Ameriteach/UCI, Chip Hillman, Ed Stepian, and Debby Stepian of the Orange County Sheriff's Office; Mary Anne Vaughn of Microsoft Corporation; Melody Glover at the Kennedy Space Center; Michael Gorman and Dominic Vergata of Avon Corporation; Rick Wallace and Vicki Kyle-Flowers of Digital Equipment Corporation; Mike Meehan of Prentice Hall; Bob Barnes of Allen-Bradley; and Jim Slate, Bruce Kepley, and Ken Kelly. Also, I want to give a very big thank you to Robin at Sir Speedy.
Thanks to everyone at the Clearwater Research Group for providing the fresh academic and research environment that one needs to experiment with new technologies such as those discussed in this book.
The many students I have had the pleasure of teaching have helped a great deal with their comments and suggestions. In particular, I want to thank Connie Patton and everyone at Liberty Mutual; Rich Lagasse at Mathworks; Michael Joy at Sensitech; and Daniel Bagley.
Kasey, Tracy, Mary, and James, my children, deserve credit for their support. I wish to mention James in particular, a freshman at the University of Florida, for his fantastic job of data entry for the Mom-n-Pop Video Store database, and for providing me with the excellent opening paragraph of Chapter 16.
Lastly, and most of all, I cannot begin to thank Patty, my wife, for her support, encouragement, faith, and companionship during the development of this book and the courses that preceded it, and for all the errands, big and small, she ran for me, and for the excellent job she has done keeping the household running while I wrote this book. Without Patty, this book would literally have not been possible, especially since she helped me through a scare in which I thought the entire book was lost on my laptop - Patty found the hidden reset button on my ThinkPad!
Jim Maloney, MCSD, MCT
Honorary Research Fellow, Clearwater Research Group
St Petersburg, FL, November 1998