Languages like C#, VB .NET, and Delphi include built-in support for events, and these events become very powerful when they connect the objects and components of a system. Events make it possible for such parts to interact without any coupling. And the resulting parts can be developed and tested individuallywhich keeps the code clean and simple.
Component-based development (CBD) is an extension of object-oriented programming. CBD does away with the language and vendor-specific limitations of OOP, makes software reuse more practical and accelerates the development process. Event-based programming is the next logical step in CBD, and makes components more reusable due to their decoupled nature. But event-based systems are easier to develop, which means they’re cheaper and more reliable than traditional OOP or CBD systems.
This book teaches you how to develop software based on parts that interact primarily through an event mechanism. You’ll learn how to use events in many different situations, to solve recurring development problems without coupling. The book introduces Signal Wiring Diagram, a novel form of software diagram similar to the circuit diagrams used by hardware designers. The book concludes with a series of case studies, incorporating all featured concepts. In a nutshell, you’ll want to pick up a copy of this book because it
Le informazioni nella sezione "Riassunto" possono far riferimento a edizioni diverse di questo titolo.
Ted Faison has over 25 years of experience in the software industry and has been involved with object-oriented-programming and component-based development since the inception of those technologies. He has worked primarily in the private sector, also as a consultant for the U.S. and Italian governments. He is a member of IEEE and ACM, and an active researcher in the field of software engineering, specializing in component-based software. He is a senior software engineer at the Southern California Auto Club, where he works on the development of a large .NET distributed system for customer relationship management. Ted is the author of Component-Based Development with Visual C#, Borland C++ Object-Oriented Programming, and Graphical User Interfaces with TurboC++.
Event-Based
Programming
Taking Events to the Limit
■ ■ ■
Ted Faison
Event-Based Programming: Taking Events to the Limit
Copyright © 2006 by Ted Faison
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13: 978-1-59059-643-2
ISBN-10: 1-59059-643-9
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Lead Editor: Jonathan Hassell
Technical Reviewer: Fernando De Gasperis
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick,
Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Dominic Shakeshaft, Jim Sumser,
Keir Thomas, Matt Wade
Project Manager: Beth Christmas
Copy Edit Manager: Nicole LeClerc
Copy Editor: Nicole Abramowitz
Assistant Production Director: Kari Brooks-Copony
Production Editor: Kelly Winquist
Compositor: Susan Glinert
Proofreader: Liz Welch
Indexer: Ted Faison
Artist: Kinetic Publishing Services, LLC
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or
visit www.springeronline.com.
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA
94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit www.apress.com.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly
by the information contained in this work.
The source code for this book is available to readers at www.apress.com in the Source Code section.
vii
Contents
About the Author . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
About the Technical Reviewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
■CHAPTER 1 Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Coupling Is Inevitable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
The Coupling Symbol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Is Coupling Bad? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
The Nature of Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Static Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Dynamic Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Static vs. Dynamic Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Coupling Flavors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Logic Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Type Coupling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Signature Coupling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Coupling Space . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Coupling Charts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Coupling Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Coupling Diagrams As Guides for System Changes . . . . . . . . . . . . . . . . . . 36
Coupling Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Logic-Coupling Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Type-Coupling Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Common Coupling Scenarios . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Coupling with User-Defined Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Coupling Due to Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
Coupling Due to Method Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
■CHAPTER 2 Events and Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Defining Events and Notifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
A Brief History of Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Nomenclature and Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Event Subscription . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
The Subscription Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
viii ■CONTENTS
Subscription Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Subscription Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
■CHAPTER 3 Notification Delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Delivery Protocols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
Delivery Using Shared Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Shared Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Shared Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Semaphores . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
Serialized Connections. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Delivery Using Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Local Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Remote Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Notification Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Direct Delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Indirect Delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Delivery Synchrony . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Synchronous Delivery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Asynchronous Delivery. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
Delivery Fanout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Quality of Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Reliability. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Priority . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Throughput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
Le informazioni nella sezione "Su questo libro" possono far riferimento a edizioni diverse di questo titolo.
EUR 3,32 per la spedizione in U.S.A.
Destinazione, tempi e costiEUR 2,34 per la spedizione in U.S.A.
Destinazione, tempi e costiDa: HPB-Red, Dallas, TX, U.S.A.
Hardcover. Condizione: Good. Connecting readers with great books since 1972! Used textbooks may not include companion materials such as access codes, etc. May have some wear or writing/highlighting. We ship orders daily and Customer Service is our top priority! Codice articolo S_395300142
Quantità: 1 disponibili
Da: ThriftBooks-Atlanta, AUSTELL, GA, U.S.A.
Hardcover. Condizione: Very Good. No Jacket. May have limited writing in cover pages. Pages are unmarked. ~ ThriftBooks: Read More, Spend Less 2.85. Codice articolo G1590596439I4N00
Quantità: 1 disponibili
Da: Good Buy 2 You LLC, Fredericksburg, VA, U.S.A.
Hardcover. Condizione: Very Good. Very clean copy. No markings. Sturdy binding. Codice articolo B-22-015
Quantità: 1 disponibili
Da: GreatBookPrices, Columbia, MD, U.S.A.
Condizione: New. Codice articolo 4130724-n
Quantità: 15 disponibili
Da: BargainBookStores, Grand Rapids, MI, U.S.A.
Hardback or Cased Book. Condizione: New. Event-Based Programming: Taking Events to the Limit 3. Book. Codice articolo BBS-9781590596432
Quantità: 5 disponibili
Da: Basi6 International, Irving, TX, U.S.A.
Condizione: Brand New. New. US edition. Expediting shipping for all USA and Europe orders excluding PO Box. Excellent Customer Service. Codice articolo ABEJUNE24-195518
Quantità: 1 disponibili
Da: Romtrade Corp., STERLING HEIGHTS, MI, U.S.A.
Condizione: New. This is a Brand-new US Edition. This Item may be shipped from US or any other country as we have multiple locations worldwide. Codice articolo ABNR-144345
Quantità: 1 disponibili
Da: California Books, Miami, FL, U.S.A.
Condizione: New. Codice articolo I-9781590596432
Quantità: Più di 20 disponibili
Da: BennettBooksLtd, North Las Vegas, NV, U.S.A.
hardcover. Condizione: New. In shrink wrap. Looks like an interesting title! Codice articolo Q-1590596439
Quantità: 1 disponibili
Da: GreatBookPricesUK, Woodford Green, Regno Unito
Condizione: New. Codice articolo 4130724-n
Quantità: Più di 20 disponibili