Visual Basic Object and Component Handbook

( 2 )

Overview

  • Enterprise, Intranet, and Internet Development
  • Windows 2000 COM+ Services
  • MTS, ASP, COM/DCOM, COM+, ADO
  • Benchmarking and Design Guidance

The Complete Guide to Object and Component Use, Design and ...

See more details below
Available through our Marketplace sellers.
Other sellers (Paperback)
  • All (17) from $1.99   
  • New (4) from $48.51   
  • Used (13) from $1.99   
Close
Sort by
Page 1 of 1
Showing 1 – 3 of 4
Note: Marketplace items are not eligible for any BN.com coupons and promotions
$48.51
Seller since 2014

Feedback rating:

(0)

Condition:

New — never opened or used in original packaging.

Like New — packaging may have been opened. A "Like New" item is suitable to give as a gift.

Very Good — may have minor signs of wear on packaging but item works perfectly and has no damage.

Good — item is in good condition but packaging may have signs of shelf wear/aging or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Acceptable — item is in working order but may show signs of wear such as scratches or torn packaging. All specific defects should be noted in the Comments section associated with each item.

Used — An item that has been opened and may show signs of wear. All specific defects should be noted in the Comments section associated with each item.

Refurbished — A used item that has been renewed or updated and verified to be in proper working condition. Not necessarily completed by the original manufacturer.

New
0130230731 New Book. Please allow 4-14 business days to arrive. We will ship Internationally as well. Very Good Customer Service is Guaranteed!! Millions sold offline.

Ships from: Newport, United Kingdom

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
$48.51
Seller since 2014

Feedback rating:

(0)

Condition: New
0130230731 New Book. Please allow 4-14 business days to arrive. We will ship Internationally as well. Very Good Customer Service is Guaranteed!! Millions sold offline.

Ships from: Newport, United Kingdom

Usually ships in 1-2 business days

  • Canadian
  • International
  • Standard, 48 States
  • Standard (AK, HI)
$125.00
Seller since 2014

Feedback rating:

(113)

Condition: New
Brand new.

Ships from: acton, MA

Usually ships in 1-2 business days

  • Standard, 48 States
  • Standard (AK, HI)
Page 1 of 1
Showing 1 – 3 of 4
Close
Sort by
Sending request ...

Overview

  • Enterprise, Intranet, and Internet Development
  • Windows 2000 COM+ Services
  • MTS, ASP, COM/DCOM, COM+, ADO
  • Benchmarking and Design Guidance

The Complete Guide to Object and Component Use, Design and Development!

  • Integrating VB6 objects and components with databases, Web sites, and Internet applications
  • MTS, ASP, COM/DCOM, COM+, ADO, and more
  • Covers the entire lifecycle: planning, design, implementation, distribution, and beyond
  • Data bound objects, design time controls, Activex, Internet, and script components, COM add-ins, and more
  • Detailed server-side coverage
  • Real benchmarks and practical design guidance

The developer's guide to VB objects and components!

Visual Basic Object and Component Handbook is the resource for building VB6 objects and components—the key to successful large-scale VB development! Whether you're developing for the enterprise, the Web, or both, Peter Vogel gives you the real-world insight and industrial-strength code you need to get results.

Start with a close look at the issues involved with building objects and their interfaces using VB6—including important design and maintenance tradeoffs you must know about up front. Next, learn all the fundamentals: choosing and implementing methods, properties, and events; building collections; combining objects into components; and more.

Then, master every key object technology Microsoft provides for distributed development, including the Component Object Model (COM), Active Server Pages (ASP), and the Microsoft Transaction Server (MTS). Learn how tocreate objects that pass data to Activex Data Objects; build components that work with Microsoft Transaction Server—even work with Windows 2000 COM+ Services.

Read More Show Less

Product Details

  • ISBN-13: 9780130230737
  • Publisher: Pearson Education
  • Publication date: 5/25/2000
  • Series: Prentice Hall Microsoft Technology Series
  • Edition description: REVISED
  • Pages: 668
  • Product dimensions: 7.03 (w) x 9.24 (h) x 1.84 (d)

Read an Excerpt

PREFACE:

Preface

In the Microsoft and Windows world, objects and components form the foundation on which everything else rests. The mortar for this foundation is Microsoft's Component Object Model (COM) specification and implementation. The COM specification describes how objects can be assembled into components and how components can work together to form applications. The implementation of COM in the Windows operating system provides the support to take advantage of this powerful technology. To participate in the world of COM, you need to create components that will work with any other COM-compliant development tool and application.

I wrote this book to provide the working Visual Basic programmer with something that I wanted: A one-volume reference to writing COM-based objects and components using Visual Basic. My goal was to provide, in one place, in plain language, everything that the Visual Basic programmer would need to know to create components.

COM and Visual Basic

COM is constantly evolving. Currently COM is being expanded into the COM+ specification in Windows 2000. In both the COM and COM+ models, developers create objects and then combine them to form components. Once built, your components can be integrated with applications built with other development tools ranging from C++ to Delphi to Object COBOL. COM-based applications that can use your components include both Microsoft Word and Internet Information Server. Building on COM, Microsoft has also defined a series of environments—including Microsoft Transaction Server and Activex Data Objects—that require objects with specific characteristics. It's a very big worldout there.

Fortunately, Microsoft has provided a terrific tool for creating objects: Visual Basic. Much of the drudgery involved in creating COM objects and components is taken care of automatically by Visual Basic so that you can concentrate on solving problems. There's still a lot that you have to know, as this book demonstrates, but Visual Basic lets you concentrate on the important issues.

I've taken a very practical approach in this book. Throughout the book, I'm going to tell you two things:

  1. If you want to do this using Visual Basic, here's the code that you should write.
  2. If you write this code, here's what Visual Basic will do.

Or, more simply: If you want this, code this; if you code this, you'll get this. Where Visual Basic gives you different implementation choices, I've described the costs and benefits from a design and maintenance point of view for each choice. I've also provided benchmarking information on the impact on your code's performance. I can't tell you what the right answer is for each one of these choices, because too much depends on what you are trying to accomplish with your program. However, if you're wondering what threading model to use or whether to declare your parameters as ByVal or ByRef, this book will give you the background to make an informed decision.

I've given design considerations precedence over performance. I don't want to suggest that performance isn't important-the application with the sub-two-second response time and a few bugs will be implemented before the application with plus-six-second response time and no bugs. But for your application to succeed, you must first get the design right and then make the adaptations necessary to get the performance you need. I firmly believe that it's often better to abandon a project than compromise the design in order to meet the performance goals. For most applications, the life cycle cost of a bad design will swallow whatever benefits the application was supposed to deliver.

Good design and good performance are not incompatible. If the design is right, then you will probably find that modifying it where necessary to improve the performance is relatively straightforward. Throughout this book I will be pointing out where you have opportunities to ensure that your component will run quickly, along with the costs and benefits of building your component that way.

The Knowledge Gap

Back in the early '80's, I started out programming on mainframe computers and creating linear programs-programs that started executing on the first line of code and kept going until they got to the end of the code. I inserted Do loops, If...Then statements, and subroutines or functions to break up the monotony, but mostly my programs began at the beginning and ran until the end.

Programming doesn't work that way anymore. My first exposure to this new world was when I started creating programs using Visual Basic 3.0. My first exposure to "programmer's culture shock" was when Visual Basic introduced me to event-driven programming. In event-driven programming I had to give up control over the execution of my program; the events that were triggered by the user determined the order in which my code executed.

When I started developing programs in Visual Basic, I also began to work with the objects that made up the Visual Basic environment. I had experimented with object-oriented programming earlier in my career by learning Smalltalk, the language that pioneered object-oriented development. I discovered that, while I had learned the syntax of the language and could write Smalltalk code, I still couldn't create Smalltalk applications. I just didn't know where to begin. Visual Basic turned out to be the tool that moved me from the world of linear programming to the world of working with objects.

For the last three years, in addition to developing Visual Basic applications, I've been teaching Visual Basic to developers for Learning Tree International. Many developers in my classes suffered the same problem that I had in getting started with object oriented development. These programmers found themselves in the position of knowing all the necessary syntax, but unsure about how to put it all together. Experienced developers in my classes found that they knew only part of what Visual Basic could do for them.

It was to address this gap between knowledge and performance that I wrote this handbook. In addition to teaching and developing, I wanted to provide developers not only with the knowledge on how to use Visual Basic's ability to create objects, but also the "when and why" of using objects.

The Handbook

I edit the Smart Access newsletter (the leading source for technical information on Microsoft Access). While working for Learning Tree, I also wrote a course on developing Web-based applications. If you read the various magazines about programming with Visual Basic, then you've probably read an article that I've written. As a result, I've had a lot of experience in explaining technical concepts to programmers. More important, I've had a lot of feedback from students, teachers, authors, peers, and others on what works and doesn't work. I've learned that the key to presenting information successfully is to provide a solid structure to organize the material.

This handbook's structure is simple. The first three parts of the handbook discuss designing objects, creating objects and components, and integrating components into specific environments. The fourth part is a "heads-up" look at what changes you can expect in Windows 2000.

Part 1 of this book covers the issues involved in designing objects. In this part, I discuss what you should consider when designing the interface for your objects. Among other topics, I'll look at deciding when you should use a method or a property, and how to derive your object design from your data design. I also show you how to use Visual Modeler, the object design tool that comes with Visual Basic.

Part 2 provides you with a complete guide to creating objects and components, including the code you need to write to implement methods, properties, and events. You'll see how to develop objects that act as collections and how to create objects that create other objects. In this part I also show you how to combine your objects to create components and cover both the why and how of implementing interfaces. Thanks to Visual Basic, your components can be as complicated as Microsoft's Data Access Objects or as simple and powerful as Activex Data Objects.

The examples in Part 2 are deliberately simple: Just enough code to demonstrate the technique. However, objects are really interesting only when they are put together and interact with each other. To demonstrate this, most of the chapters in Part 2 end with a case study that shows the various techniques in action. Even in these final sections, I've kept the standard "business" code to a minimum so that you can concentrate on the code that makes the objects work. The error handling that a real business application would require is missing, for instance.

With a foundation on how to build objects and components in place, Part 3 looks at how to create objects that will work in the specialized environments that Microsoft has defined. You'll see how to create an object that can pass data into to Activex Data Objects and what you must do to create a component that will work with Microsoft Transaction Server. In Part 4, I look at what Windows 2000 developers can expect to find under COM+ and Component Services.

Benchmarks

Throughout Part 2 of this book I've given examples of the impact on execution time of the programming decisions that you will make. If you are trying to decide whether to use a ParamArray or a set of optional parameters, these benchmarks should provide you with the information to make a performance-based decision. However, performance isn't everything, as you know if you've ever tried to maintain someone else's "highly optimized" code. And, in many cases, a foolish emphasis on writing the fastest code leads to introducing bugs. To paraphrase the immortal words of the authors of The Fundamentals of Programming Style, to some programmers, efficiency often seems to mean getting to the wrong answer as fast as possible.

Overreliance on benchmarks can be a mistake. As you look at the benchmark results remember that I repeated most operations 1000 times. So, when I say that an operation took 2 milliseconds on my computer, that really means that one execution took 2/1000 milliseconds. You should recognize that even a difference of an order of magnitude may translate into less than a millisecond. Do you really need to worry about a millisecond? And, if you do, shouldn't you be writing this code in C and not Visual Basic? If you are concerned about the assumptions that I've made, you can find the code in Appendix B, the Benchmarking Code appendix. You can also download the code (and the COM Add-in that generated it) from my Website at ....

Keep in Touch

I've had a lot of fun writing this book and exploring Microsoft's world of objects. I wrote the book because I wanted to provide a single reference to all the information that you might need when building components with Visual Basic. I hope you get as much satisfaction out of using this book as I did writing it. If you have any questions, issues, concerns, or recommendations don't hesitate to drop me a line at peter.vogel@phvis.com. You're also welcome anytime at the PH&V Information Services website at .... In addition to finding the Visual Basic COM Add-in that generated the benchmarks in Part 2, you'll find white papers on a variety of topics in application development.

And, for those of you who've read Ken's Foreword: the Empire State Building has 6,500 windows (though I suspect that the number has been rounded), and the boiling point of bleach (typically, water with a 5% solution of NaOCI) is close to the boiling point of water at 212°F/100°C.

Read More Show Less

Table of Contents

I. DESIGNING.

1. Designing Components.
Defining Objects. Designing Objects. Objects for the Database Developer. Objects and the Visual Basic Programmer. An Object Model Case Study. Object Overview. Object Relationships. Object Detail. Handling Interfaces. Designing the Object Interface. Properties and Methods. Interface Guidelines. Events. Naming Names. Public and Private Interfaces. Root Objects. Summary.

2. Visual Modeler.
Modeling Tools and Health Clubs. Visual Modeler Benefits and Limitations. What Visual Modeler Does. What Visual Modeler Doesn't Do. A Word From the Wise. UML Benefits and Limitations. Methodology. Implementation. UML and Visual Basic. Working With Visual Modeler. Reverse Engineering With Visual Modeler. The Visual Modeler Display. Manipulating Items and Diagrams. Component View. Adding Components and Component Diagrams. Dependencies. Component Specifications. Class Diagram. Class Specifications. Class Associations. Code Generation. Code Generation Options. Non Code-Generation Related Features. Text Boxes and Notes. The Deployment Diagram. Packages. Reports. Integration. Summary.

II. BUILDING.

3. Coding Objects.
Parameters. Optional Parameters. ParamArrays. Named Parameters. Default Values. ByVal and ByRef. User Defined Types. UDT Workarounds. UDT Support. Enums. Naming Names. Powers of 2. The Basics of Objects. Adding Objects. Working With Objects. New and CreateObject. GetObject. Instantiation.Object References. Activex Controls. Variables. Object Variables. CallByName. Case Study: Experimenting With Objects. Coding the Object. Coding the Program. Running the Experiment. Working with Objects. Experimental Lessons. ByVal and ByRef Object Parameters. Summary.

4. Objects.
Working With Class Modules. Classes. Defining Methods. Defining Properties. Public Variables. Property Procedures. Property Let. Property Get. Property Set. Combining Let and Set. Property Exit. Multiple Parameter Properties. Property Data Type. Debugging Error Handling. Persisting Objects. Persistence Events. Saving an Object. Saving the PropertyBag. Restoring the Object. Other Uses. Me. Managing State. Events. Declaring Events. Firing Events. WithEvents. Events with Parameters. Some Restrictions. The ObjPtr Function. Case Study: Asynchronous Methods. Using the Timer Object. The Asynchronous Method. Notifying the Client. Shutting the Object Down. Using a Property. Using an Event. Summary.

5. Components.
Using Components. The References List. CreateObject in Detail. GetObject. Component Definitions. Components and Applications. Objects and Components. Defining a Component. COM Interfaces. Initial Project Options. Assigning Names. Adding Objects. Testing. Debugging Options. Simple and Complex Components. Instancing for Simple Objects. SingleUse versus MultiUse Efficiency Issues. Sharing. Complex Components. Multiple SingleUse Components. MultiUse and SingleUse Components. Controlling Component Creation. Using Objects in the Same Component. Global Objects. Using a Global Object. Global Instancing. Component Design Strategies. Activex EXE. Share All. One Copy Each. Multiple Copies/No Sharing. Activex DLL. Objects That Create Objects. Initializing. Case Study: The WholesaleManagement Components. Summary.

6. Interfaces.
Object Interfaces. COM Interfaces. Visual Basic and Interfaces. Interfaces and Object Variables. Using Multiple Object Variables. Summing Up. Using COM Interfaces. Adding Interfaces. Accessing Interface Routines. Reducing Code. Implements and Events. Class Module Types. Why Interfaces? Managing Development. Extensibility. Early binding. Other Interface Benefits. Versioning. Case Study: Managing Versions. Hiding Interfaces. Hiding Methods and Properties with Friend. Hiding Objects. User Interfaces. Standalone Components. Suppressing the UI. Logging. Procedure Attributes. Dispatch Ids. Basic Attributes. Advanced Attributes. Creating a Collection Interface. Defining A Simple Collection. Loading the Collection. Returning a Collection. Managing the Collection. A Complete Collection. Enumerating a Collection. A Large Collection: Simple Version. A Large Collection: Complete Version. Case Study: Callbacks. Summary.

7. Deploying.
Performance Matters. Performance Costs. Improving Performance. Talking to Objects. In Process and Out-of-Process. Address Spaces. EXEs. DLLs. DCom and Remote Objects. Load Points. ByVal and ByRef, Methods and Functions. A Final Warning. Threading. Thread Basics. Thread Benefits and Costs. Threading Dangers. Threads and Activex DLLs. Threads and Activex EXEs. Thread Decisions. Internal Creates. Identifiers. Generating GUIDs. Changing GUIDs. No Compatibility. Binary Compatibility. Project Compatibility. Version Numbers. Installing Components. Tools. Remote Server Files and CliReg. DCOM and DCOMCNFG. Dependencies. Uninstall. Package and Deployment Wizard. Creating Packages. Script Files. Deploy. Visual Component Manager. Working with VCM. Retrieving a Component. Publishing a Component. Changing a Component. VCM Issues. Summary.

III. INTEGRATING.

8. Activex Controls.
Introducing Activex Controls. A Typical Activex Control. Activex Control Projects. Debugging an Activex Control. Activex Controls and Visual Basic. UserControl Lifecycle Events. The Life Cycle of an Activex Control. InitProperties. WriteProperties. ReadProperties. UserControl Properties. AccessKeys. The AccessKeyPress Event. Constituent Controls. Alignable. BackStyle. Windowless Controls. ClipBehavior. MaskPicture and MaskColor. The HitTest Event. A HitTest Example. HitBehavior. CanGetFocus. ControlContainer. ContainedControls. ContainerHwnd. DefaultCancel. EditAtDesignTime. EventsFrozen. ForwardFocus. Hyperlink. InvisibleAtRunTime. Parent. ParentControls. Public. ToolboxBitmap. Windowless. The Extender Object. Using the Extender Object. Extender Limitations. Duplicating Names. The Ambient Object. AmbientChanged Event. UserControl Events. EnterFocus, ExitFocus. Hide. Show. Supporting InvisibleAtRunTime. UserControl Methods. AsyncRead. A Sample AsyncRead. PropertyChanged. Procedure Attributes. Procedure ID. AboutBox. Enabled. Text and Caption. Don't Show in Property Browser. Property Category. User Interface Default. Property Pages. Associating a Property Page With a Control. The Life of a PropertyPage. Object Type Properties. PropertyPage Properties. The StandardSize Property. The Changed Property. SelectedControls and SelectionChanged. PropertyPage Events. ApplyChanges. EditProperty. Distributing. Internet Downloads. Authenticode. Safety. IObjectSafety. Licensing. Summary.

9. Data Binding, Providers, Consumers, and RDS.
Data Bound Controls. DataField Binding. Other Options. Activex Data Providers. Data Providers. The GetDataMember Event. DataMember. Provider Methods. OLE DB Providers. Creating the Provider. Updates. Commands. Events. Data Consumers. Simple Data Consumer. BindingCollection. PropertyChanged. Service Provider Objects. Defining a Service Provider. Building A Chain. A Sample Chain. Remote Data Services. An RDS Case Study. RDS Architecture. The Default DataFactory. Custom DataFactories. Summary.

10. Design Time Controls.
Introducing DTC. Designing a Simple DTC. RDS. The DTCRDS Specification. An Activex Control. Defining Properties. Persisting Properties. The Design Time Control Interface. The GetRunTimeText Method. DTC Output. Registering the DTC. Using the Simple DTC. Integrating Design-Time Controls. Choices. Publishing a Choice. Subscribing to a Choice. Rebinding. Selecting a Choice Object. Tags. User Interface. Callbacks and PopUps. Dynamic Choices. Destroying the Object. Persisting the Object. Debugging. Choice Inspector. Publishing an Object Model. Scenarios. Building a Model. Other Options. Summary.

11. Activex Documents.
What Is an Activex Document? The Life Cycle of an Activex Document. Developing. Containers Matter. Internet Explorer. Microsoft Office Binder. Visual Basic IDE. Container Differences. The Viewport. Activex Documents Applications. Getting Started. EXE or DLL. UserDocument Events. Startup and Termination Events. Scroll Event. UserDocument Methods. Positioning the Viewport. UserDocument Properties. HSmallScrollChange, VSmallScrollChange. Scrollbars. MinHeight, MinWidth. ViewportHeight, ViewportWidth, ViewportLeft, ViewportTop. Debugging Activex Documents. Menu Negotiation. Implementing and Distributing. Issues in Activex Document Development. Managing State. Determining the Container. Exploiting VBD Files. Cooperating UserDocuments. Activex Documents and Visual Basic Applications. Summary.

12. Microsoft Transaction Server Objects.
MTS Architecture. Creating a Package. Configuring the Package. The ObjectContext Object. MTS Services. Transaction Management. MTS Transaction Management. Starting a Transaction. Integrating Transaction Management. Coordinating Updates. Security. Programmatic Security. Scalability. Loading and Unloading. State Management. The Shared Property Manager. Activation and Deactivation. Pooling Objects. Returning References. Distributing. Debugging. Summary.

13. Internet Components.
I*Net Applications. Client/Server Development on the Web. HTML and DHTML Elements. The Microsoft Tools. Web Development With Visual Basic. Activex Designers. Using an Activex Designer. DHTML Applications. Creating a DHTML Project. The DHTML Designer. The DHTMLPage Object. State Management. Debugging and Deploying. IIS Applications. The Life Cycle of an IIS Application. Creating an IIS Application. The IIS Application Designer. Using Templates. Using the ASP Objects. IIS Events. WebClass Processing Cycle. Custom Events. Using the NextItem Property. Maintaining State. Controlling Form Flow. Why You Don't Need IIS Applications. Debugging IIS Applications. Deploying IIS Applications. Summary.

14. Script Components.
Introducing Scripting. Activex Scripting. VBScript. Scripting Hosts. Windows Script Host. Using Objects from the Windows Script Host. DHTML Scriptlets. Creating a DHTML Scriptlet Object. Methods, Properties, and Events. Remote Scripting and ASP Remote Objects. On the Server. On the Client. The Call Object. Defining Script Components. XML. Creating a Script Component. Package and Component Tags. Reference, Resource, and Object Tags. Comment Tags. The Registration Tag. Event Tag. Property Tag. Method Tag. The Component, XML, and CDATA Directives. Implements. Registering Script Components. Type Libraries. Using a Scripting Component. Visual Basic. The Window Script Host and ASP. The DHTML Behavior Interface. Assigning Behaviors. Defining the DHTML Behavior. Attaching Events. Event Tag. Property and Method Tags. Behavior Methods and Properties. Element Property. createEventObject. Tools. Summary.

15. COM Add-Ins.
Truth in Marketing. COM Add-ins and the Windows Registry. Visual Basic 5. The Life Cycle of an Add-in. Connecting and Disconnecting. Creating COM Add-ins. Getting Started. OnConnection Routine. OnDisconnection Parameters. Sharing Code. The Connection Designer. The Default Code. Application, Application Version. LoadBehavior. Display Name, Description, Addin is Command-line safe. The Advanced Tab. Integrating Your Add-in and the Host. Displaying a Form. Displaying an Activex Document. Responding to Events. Adding Your Add-in to a Menu. Adding a Menu. Adding a Menu Item. Removing a Menu Item. Responding to Events. Debugging and Deploying. Summary.

IV. WINDOWS 2000.

16. Component Services.
Component Services Concepts. Contexts and Configurations. COM+ Features. No Longer Required. Not Yet Available. Load Balancing. Queued Components. Calling a Queued Component. Receiving a Message. Loosely Coupled Events. Constructors. More Security Objects. Debugging COM+. Deploying COM+ Applications. Visual Studio Installer. Summary.

V. APPENDICES.

APPENDIX A: The Wholesale Management Database.
The Database. Relational Tables. Splitting Tables. Relationships. Summary.

Appendix B: Benchmark Code.
The Benchmark Add-In. Sample Code. Main Routine. Multiple Parameters. Optional Parameters. Default Parameters. ByVal Parameters. User Defined Types as Parameters. User Defined Types as Return Values. Using Enums, Constants, and Variables. Assigning Variables, Constants, and Enums. Using Objects as Parameters. Returning Different DataTypes From Functions. Comparing Property Implementations. Setting Object Properties Using Set and Let. Returning Multiple Parameters from an Event. Using ByVal Parameters on an Event. Comparion of SingleUse and MultiUse Load. Calling Methods on Global and MultiUse Objects. Implemented vs Native Methods. Methods Implemented as Functions and Subroutines. Parameters with Out-Of-Process and In-Process Components. Returning Values from Out-of-Process and In-Process Components. About the Author.

Index.
Read More Show Less

Preface

PREFACE:

Preface

In the Microsoft and Windows world, objects and components form the foundation on which everything else rests. The mortar for this foundation is Microsoft's Component Object Model (COM) specification and implementation. The COM specification describes how objects can be assembled into components and how components can work together to form applications. The implementation of COM in the Windows operating system provides the support to take advantage of this powerful technology. To participate in the world of COM, you need to create components that will work with any other COM-compliant development tool and application.

I wrote this book to provide the working Visual Basic programmer with something that I wanted: A one-volume reference to writing COM-based objects and components using Visual Basic. My goal was to provide, in one place, in plain language, everything that the Visual Basic programmer would need to know to create components.

COM and Visual Basic

COM is constantly evolving. Currently COM is being expanded into the COM+ specification in Windows 2000. In both the COM and COM+ models, developers create objects and then combine them to form components. Once built, your components can be integrated with applications built with other development tools ranging from C++ to Delphi to Object COBOL. COM-based applications that can use your components include both Microsoft Word and Internet Information Server. Building on COM, Microsoft has also defined a series of environments—including Microsoft Transaction Server and Activex Data Objects—that require objects with specific characteristics. It's a very bigworldout there.

Fortunately, Microsoft has provided a terrific tool for creating objects: Visual Basic. Much of the drudgery involved in creating COM objects and components is taken care of automatically by Visual Basic so that you can concentrate on solving problems. There's still a lot that you have to know, as this book demonstrates, but Visual Basic lets you concentrate on the important issues.

I've taken a very practical approach in this book. Throughout the book, I'm going to tell you two things:

  1. If you want to do this using Visual Basic, here's the code that you should write.
  2. If you write this code, here's what Visual Basic will do.

Or, more simply: If you want this, code this; if you code this, you'll get this. Where Visual Basic gives you different implementation choices, I've described the costs and benefits from a design and maintenance point of view for each choice. I've also provided benchmarking information on the impact on your code's performance. I can't tell you what the right answer is for each one of these choices, because too much depends on what you are trying to accomplish with your program. However, if you're wondering what threading model to use or whether to declare your parameters as ByVal or ByRef, this book will give you the background to make an informed decision.

I've given design considerations precedence over performance. I don't want to suggest that performance isn't important-the application with the sub-two-second response time and a few bugs will be implemented before the application with plus-six-second response time and no bugs. But for your application to succeed, you must first get the design right and then make the adaptations necessary to get the performance you need. I firmly believe that it's often better to abandon a project than compromise the design in order to meet the performance goals. For most applications, the life cycle cost of a bad design will swallow whatever benefits the application was supposed to deliver.

Good design and good performance are not incompatible. If the design is right, then you will probably find that modifying it where necessary to improve the performance is relatively straightforward. Throughout this book I will be pointing out where you have opportunities to ensure that your component will run quickly, along with the costs and benefits of building your component that way.

The Knowledge Gap

Back in the early '80's, I started out programming on mainframe computers and creating linear programs-programs that started executing on the first line of code and kept going until they got to the end of the code. I inserted Do loops, If...Then statements, and subroutines or functions to break up the monotony, but mostly my programs began at the beginning and ran until the end.

Programming doesn't work that way anymore. My first exposure to this new world was when I started creating programs using Visual Basic 3.0. My first exposure to "programmer's culture shock" was when Visual Basic introduced me to event-driven programming. In event-driven programming I had to give up control over the execution of my program; the events that were triggered by the user determined the order in which my code executed.

When I started developing programs in Visual Basic, I also began to work with the objects that made up the Visual Basic environment. I had experimented with object-oriented programming earlier in my career by learning Smalltalk, the language that pioneered object-oriented development. I discovered that, while I had learned the syntax of the language and could write Smalltalk code, I still couldn't create Smalltalk applications. I just didn't know where to begin. Visual Basic turned out to be the tool that moved me from the world of linear programming to the world of working with objects.

For the last three years, in addition to developing Visual Basic applications, I've been teaching Visual Basic to developers for Learning Tree International. Many developers in my classes suffered the same problem that I had in getting started with object oriented development. These programmers found themselves in the position of knowing all the necessary syntax, but unsure about how to put it all together. Experienced developers in my classes found that they knew only part of what Visual Basic could do for them.

It was to address this gap between knowledge and performance that I wrote this handbook. In addition to teaching and developing, I wanted to provide developers not only with the knowledge on how to use Visual Basic's ability to create objects, but also the "when and why" of using objects.

The Handbook

I edit the Smart Access newsletter (the leading source for technical information on Microsoft Access). While working for Learning Tree, I also wrote a course on developing Web-based applications. If you read the various magazines about programming with Visual Basic, then you've probably read an article that I've written. As a result, I've had a lot of experience in explaining technical concepts to programmers. More important, I've had a lot of feedback from students, teachers, authors, peers, and others on what works and doesn't work. I've learned that the key to presenting information successfully is to provide a solid structure to organize the material.

This handbook's structure is simple. The first three parts of the handbook discuss designing objects, creating objects and components, and integrating components into specific environments. The fourth part is a "heads-up" look at what changes you can expect in Windows 2000.

Part 1 of this book covers the issues involved in designing objects. In this part, I discuss what you should consider when designing the interface for your objects. Among other topics, I'll look at deciding when you should use a method or a property, and how to derive your object design from your data design. I also show you how to use Visual Modeler, the object design tool that comes with Visual Basic.

Part 2 provides you with a complete guide to creating objects and components, including the code you need to write to implement methods, properties, and events. You'll see how to develop objects that act as collections and how to create objects that create other objects. In this part I also show you how to combine your objects to create components and cover both the why and how of implementing interfaces. Thanks to Visual Basic, your components can be as complicated as Microsoft's Data Access Objects or as simple and powerful as Activex Data Objects.

The examples in Part 2 are deliberately simple: Just enough code to demonstrate the technique. However, objects are really interesting only when they are put together and interact with each other. To demonstrate this, most of the chapters in Part 2 end with a case study that shows the various techniques in action. Even in these final sections, I've kept the standard "business" code to a minimum so that you can concentrate on the code that makes the objects work. The error handling that a real business application would require is missing, for instance.

With a foundation on how to build objects and components in place, Part 3 looks at how to create objects that will work in the specialized environments that Microsoft has defined. You'll see how to create an object that can pass data into to Activex Data Objects and what you must do to create a component that will work with Microsoft Transaction Server. In Part 4, I look at what Windows 2000 developers can expect to find under COM+ and Component Services.

Benchmarks

Throughout Part 2 of this book I've given examples of the impact on execution time of the programming decisions that you will make. If you are trying to decide whether to use a ParamArray or a set of optional parameters, these benchmarks should provide you with the information to make a performance-based decision. However, performance isn't everything, as you know if you've ever tried to maintain someone else's "highly optimized" code. And, in many cases, a foolish emphasis on writing the fastest code leads to introducing bugs. To paraphrase the immortal words of the authors of The Fundamentals of Programming Style, to some programmers, efficiency often seems to mean getting to the wrong answer as fast as possible.

Overreliance on benchmarks can be a mistake. As you look at the benchmark results remember that I repeated most operations 1000 times. So, when I say that an operation took 2 milliseconds on my computer, that really means that one execution took 2/1000 milliseconds. You should recognize that even a difference of an order of magnitude may translate into less than a millisecond. Do you really need to worry about a millisecond? And, if you do, shouldn't you be writing this code in C and not Visual Basic? If you are concerned about the assumptions that I've made, you can find the code in Appendix B, the Benchmarking Code appendix. You can also download the code (and the COM Add-in that generated it) from my Website at ....

Keep in Touch

I've had a lot of fun writing this book and exploring Microsoft's world of objects. I wrote the book because I wanted to provide a single reference to all the information that you might need when building components with Visual Basic. I hope you get as much satisfaction out of using this book as I did writing it. If you have any questions, issues, concerns, or recommendations don't hesitate to drop me a line at peter.vogel@phvis.com. You're also welcome anytime at the PH&V Information Services website at .... In addition to finding the Visual Basic COM Add-in that generated the benchmarks in Part 2, you'll find white papers on a variety of topics in application development.

And, for those of you who've read Ken's Foreword: the Empire State Building has 6,500 windows (though I suspect that the number has been rounded), and the boiling point of bleach (typically, water with a 5% solution of NaOCI) is close to the boiling point of water at 212°F/100°C.

Read More Show Less

Customer Reviews

Average Rating 4.5
( 2 )
Rating Distribution

5 Star

(1)

4 Star

(1)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Anonymous

    Posted August 24, 2000

    Excellent review of VB Objects

    I have looked at just about every book on Objects and Visual Basic and this is one of three I would recommend.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted August 6, 2000

    The author's opinion

    I'm the book's author, so ignore the rating--only shame kept me from giving the book five stars. I wrote this book because I was tired of pulling together from a variety of places all the information that I needed for creating components, ActiveX Controls, ActiveX Documents, Microsoft Transaction Server objects, Visual Basic and COM Add-ins, ADO Data Providers, and all the other denizens of Microsoft's object world. In addition, for some object types, Microsoft's documentation was ambiguous, incomplete, or wrong. As a result, I kept putting together test programs to find out how things really worked (it took me five days to figure out how to build a Design Time Control, for instance). I was also interested in the performance cost of various design choices that I made in building components. So, this book is intended to act as a handbook: All the stuff that you need to create objects and components in Visual Basic from design to implementation and deployment. As Ken Getz says in the intro, the idea of a book is that it will save you more time than the price of the book. I hope that this book will do that for you. Let me know.

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)