Résumé
Written from a Visual Basic perspective, this book intends to make you comfortable with using design patterns by laying out the concept of patterns in a practical fashion. Organized as a series of short chapters that each describe a design pattern, Visual Basic Design Patterns provides one or more complete working visual examples of programs using that pattern, along with UML diagrams illustrating how the classes interact. Each example is a visual program that you can run and study on the companion CD making the pattern as concrete as possible. Programmers using this book will see significant improvement in their work by employing the following key concepts:
- Applying "tried-and-true" object-oriented design patterns in Visual Basic applications.
- Helping advance programming skills with the power of patterns.
- Understanding the interactions between classes through the use of UML diagrams.
- Getting comfortable using design patterns effectively and start using them in day-to-day Visual Basic programming.
The ideabehind design patterns is simple: it's a catalogue of common interactions between objects that programmers have found useful, enabling them to quickly and easily employ them in their programs. Visual Basic Design Patterns provides practical advice on how to use these patterns in everyday programming.
Contents
Preface.
Acknowledgements.
I. OBJECT-ORIENTED PROGRAMMING IN VB.
1. What Are Design Patterns?The Learning Process.
Studying Design Patterns.
Notes on Object Oriented Approaches.
VB Design Patterns.
How this Book is Organized.
2. UML Diagrams.
Interfaces.
Composition.
Annotation.
WithClass UML Diagrams.
Visual Basic Project Files.
3. Using Classes and Objects in VB.
Building a Temperature Class.
Putting the Decisions into the Temperature Class.
Using Classes for Format and Value Conversion.
A String Tokenizer Class.
Classes as Objects.
Class Initialization.
Classes and Properties.
Another Interface Example—The Voltmeter.
A vbFile Class.
Programming Style in Visual Basic.
Summary.
4. Object-Oriented Programming.
Creating Instances of Objects.
A VB Measurement Program.
Methods Inside Objects.
Variables.
Passing Arguments by Reference and by Value.
Object Oriented Jargon.
5.Building Your Own VB Control.
Testing Your HiText Controls.
Adding Properties and Methods to User Controls.
Compiling a User Control.
Summary.
Program on the CD-ROM.
6. Inheritance and Interfaces.
An Investment Simulator.
Writing the Simulator.
Indicators for Using an Interface.
Reusing Common Methods.
Hidden Interfaces.
Summary.
Programs on the CD-ROM.
7. Introduction to VB.NET.
Variable Declarations and Scoping.
Compiler Options.
Properties in VB6 and VB.NET.
Shorthand Equals Syntax.
Managed Languages and Garbage Collection.
Classes in VB.NET.
Building a VB7 Application.
The Simplest Window Program in VB.NET.
Inheritance.
Constructors.
Drawing and Graphics in VB.NET.
Tooltips and Cursors.
Overloading.
Inheritance.
Namespaces.
Public, Private, and Protected.
Overriding Methods in Derived Classes.
Overloading and Shadowing.
Overriding Windows Controls.
Interfaces.
Summary.
Programs on the CD-ROM.
8. Arrays, Files and Exceptions in VB.Net.
Collection Objects.
Hashtables.
SortedLists.
Exceptions.
Multiple Exceptions.
Throwing Exceptions.
File Handling.
Reading a Text File.
Writing a Text File.
Exceptions in File Handling.
Testing for End of File.
The FileInfo Class.
A vbFile Class.
Programs on the CD-ROM.
II. CREATIONAL PATTERNS.
9. The Simple Factory Pattern.
Sample Code.
The Two Derived Classe.
Building the Simple Factory.
Writing the Factory Pattern in VB.NET.
Factory Patterns in Math Computation.
Programs on the CD-ROM.
10. The Factory Method.
The Events Classes.
Straight Seeding.
Our Seeding Program.
Other Factories.
The Seeding Program in VB7.
When to Use a Factory Method.
Programs on the CD-ROM.
11. The Abstract Factory Pattern.
How the User Interface Works.
Creating an Abstract Factory Using VB7.
Handling the RadioButton and Button Events.
Adding More Classes.
Consequences of Abstract Factory.
Programs on the CD-ROM.
12. The Singleton Pattern.
Catching the Error.
Providing a Global Point of Access to a Singleton.
The MSComm Control as a Singleton.
Writing a Singleton in VB.NET.
Error Handling in Our Singleton.
A VB.NET SpoolDemo Program.
The Global Point of Access.
Other Consequences of the Singleton Pattern.
Programs on Your CD-ROM.
13. The Builder Pattern.
Calling the Builders.
The List Box Builder.
The Checkbox Builder.
Writing a Builder in VB.NET.
The CheckChoice Class.
The ListboxChoice Class.
Using the Items Collection in the ListBox Control.
Consequences of the Builder Pattern.
Programs on the CD-ROM.
14. The Prototype Pattern.
Using the Prototype.
Using the Prototype Pattern.
Dissimilar Classes with the Same Interface.
Prototype Managers.
Writing a Prototype in VB7.
Consequences of the Prototype Pattern.
Programs on the CD-ROM.
Summary of Creational Patterns.
III. Structural Patterns.
15. The Adapter Pattern.
Using the MSFlexGrid.
Using a TreeView.
Two Way Adapters.
Using Adapters in VB7.
TreeView Adapters for VB.NET.
Adapting a DataGrid.
The Class Adapter.
Two-Way Adapters.
Object versus Class Adapters in VB.NET.
Pluggable Adapters.
Adapters in VB.
Programs on the CD-ROM.
16. The Bridge Pattern.
The Class Diagram.
Extending the Bridge.
ActiveX Controls as Bridges.
The Bridge Pattern in VB.NET.
The Grid VisList Class.
Loading the Data.
Changing the Data Side of the Bridge.
Consequences of the Bridge Pattern.
Programs on your CD-ROM.
17. The Composite Pattern.
Computing Salaries.
The Employee Classes.
The Subords Class.
The Boss Class.
Building the Employee Tree.
Self-Promotion.
Doubly Linked Lists.
Consequences of the Composite Pattern.
A Simple Composite.
Composites in VB.
The Composite in VB.NET.
Multiple Boss Constructors.
Other Implementation Issues.
Programs on the CD-ROM.
18. The Decorator Pattern.
Using a Decorator.
Using ActiveX Controls as Decorators.
A Decorator In VB.NET.
Nonvisual Decorators.
Decorators, Adapters and Composites.
Consequences of the Decorator Pattern.
Programs on the CD-ROM.
19. The Facade Pattern.
Getting Data out of Databases.
Kinds of Databases.
ODBC.
Microsoft Database Connection Strategies.
Database Structure.
Building the Facade Classes.
Building the Stores and Foods Tables.
Building the Price Table.
Summary of the Facade Pattern.
ADO Database Access in VB6.
Adding and Seeking Rows Table Rows.
Using the ADO Extensions.
The ADO Dbase Class.
Database Access in VB.NET.
Using ADO.NET.
Reading Data from a Database Table.
Executing a Query.
Deleting the Contents of a Table.
Adding Rows to Database Tables Using ADO.NET.
Making the VB.NET ADO Facade.
Creating Classes for Each Table.
Storing the Prices.
Loading the Database Tables.
The Final Application.
What Constitutes the Facade?
Consequences of the Facade.
Programs on the CD-ROM.
20. The Flyweight Pattern.
Example Code.
Selecting A Folder.
Writing a Flyweight Folder in VB.NET.
Flyweight Uses in VB.
Sharable Objects.
Copy-on-Write Objects.
Programs on the CD-ROM.
21. The Proxy Pattern.
Writing a Proxy in VB.Net.
Proxies in VB.
Copy-on-Write.
Comparison with Related Patterns.
Programs on the CD-ROM.
Summary of Structural Patterns.
IV. BEHAVIORAL PATTERNS.
22. Chain of Responsibility.
Sample Code.
The List Boxes.
Programming a Help System.
A Chain or a Tree?
Chain of Responsibility in VB.NET.
Kinds of Requests.
Examples in VB.
Consequences of the Chain of Responsibility.
Programs on the CD-ROM.
23. The Command Pattern.
Command Objects.
Building Command Objects.
Arrays of Commands.
Consequences of the Command Pattern.
Providing Undo.
The Command Pattern in VB.NET.
The CommandHolder Interface.
Handling Undo Commands in VB.NET.
The Command Pattern in the VB Language.
Programs on the CD-ROM.
24. The Interpreter Pattern.
Applicability.
A Simple Report Example.
Interpreting the Language.
Objects Used in Parsing.
Reducing the Parsed Stack.
Implementing the Interpreter Pattern.
Building an Interpreter in VB.
The Parse Objects.
Consequences of the Interpreter Pattern.
Programs on the CD-ROM.
25. The Iterator Pattern.
Sample VB6 Code.
Filtered Iterators.
Iterators in VB.NET.
Consequences of the Iterator Pattern.
Programs on the CD-ROM.
26. The Mediator Pattern.
Interactions between Controls.
Sample Code.
Mediators and Command Objects.
The Mediator in VB.Net.
Handling the Events for the New Controls.
Consequences of the Mediator Pattern.
Single Interface Mediators.
Implementation Issues.
Programs on the CD-ROM.
27. The Memento Pattern.
Implementation.
Sample Code.
Command Objects in the User Interface.
Handling Mouse and Paint Events.
Writing a Memento in VB.NET.
Consequences of the Memento.
Programs on the CD-ROM.
28. The Observer Pattern.
Writing an Observer in VB.NET.
The Message to the Media.
Consequences of the Observer Pattern.
Programs on the CD-ROM.
29. The State Pattern.
Switching Between States.
How the Mediator Interacts with the State Manager.
Handling the Fill State.
Handling the Undo List.
A State Pattern in VB.NET.
Mediators and the God Class.
Consequences of the State Pattern.
State Transitions.
Programs on the CD-ROM.
30. The Strategy Pattern.
Sample Code.
The Context.
The Program Commands.
The Line and Bar Graph Strategies.
Drawing Plots in VB.
A Strategy Pattern in VB.NET.
Consequences of the Strategy Pattern.
Programs on the CD-ROM.
31. The Template Method Pattern.
Kinds of Methods in a Template Class.
Sample Code.
Drawing an Isosceles Triangle.
The Triangle Drawing Program.
Templates and Callbacks.
Summary and Consequences.
Programs on the CD-ROM.
32. The Visitor Pattern.
When to Use the Visitor Pattern.
Sample Code.
Visiting the Classes.
Visiting Several Classes.
Bosses are Employees Too.
Catch-All Operations with Visitors.
Double Dispatching.
Why Are We Doing This?
Traversing a Series of Classes.
Writing a Visitor in VB.
Consequences of the Visitor Pattern.
Programs on the CD-ROM.
Bibliography.
Index.
L'auteur - James W. Cooper
James W. Cooper is a research staff member in the Advanced Information Retrieval and Analysis Department at the IBM Thomas J. Watson Research Center. He is also a columnist for Java Pro magazine and a reviewer for Visual Basic Programmer's Journal. He has published 14 books, which include Principles of Object-Oriented Programming Using Java 1.1 (Ventana) and The Visual Basic Programmer's Guide to Java (Ventana).
Caractéristiques techniques
PAPIER | |
Éditeur(s) | Prentice Hall |
Auteur(s) | James W. Cooper |
Parution | 18/12/2001 |
Nb. de pages | 484 |
Format | 18,5 x 23,3 |
Couverture | Broché |
Poids | 750g |
Intérieur | Noir et Blanc |
EAN13 | 9780201702651 |
Avantages Eyrolles.com
Consultez aussi
- Les meilleures ventes en Graphisme & Photo
- Les meilleures ventes en Informatique
- Les meilleures ventes en Construction
- Les meilleures ventes en Entreprise & Droit
- Les meilleures ventes en Sciences
- Les meilleures ventes en Littérature
- Les meilleures ventes en Arts & Loisirs
- Les meilleures ventes en Vie pratique
- Les meilleures ventes en Voyage et Tourisme
- Les meilleures ventes en BD et Jeunesse