Automate dependency tracking, Part 1
Design an information model for automatically discovering dependencies in interactive object-oriented applications
By Michael L. Perry, JavaWorld.com, 08/15/01
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
In any interactive application, dependency tracking is one of the most significant problems you must solve. Usually, you apply
some manual mechanism to update user interface (UI) components when the information model changes. For example, you might
use the Observer pattern to notify registered objects of changes to a given subject. Or you might use the Publish/Subscribe
pattern to broadcast changes to all listeners. Or you can route update messages with appropriate hints to all views. All these
mechanisms work, but they all require effort by a person -- and that person will be you, the overworked programmer.
An automatic dependency tracking mechanism can handle most of that work for you. Using the automatic mechanism resembles programming
with a spreadsheet; you simply enter formulas, and the computer figures out when to calculate them. The major difference is
that the automatic mechanism is object-oriented and speaks Java.
The choice to track dependencies automatically is not based on laziness -- well, not entirely. By relieving the programmer
from manually tracking dependencies, an automatic dependency mechanism removes a potential bug source. It also reduces the
work needed to add features to the program. With a manual dependency mechanism, a program addition usually requires you to
revisit prior dependencies to keep the user interface in sync with the model. However, when dependency is tracked automatically,
the program discovers new dependencies on its own at runtime, with no programmer intervention. Of course, setting up such
a mechanism takes some preparation.
In this series, you will learn what it takes to create an interactive application using automatic dependency tracking. Automatic dependency tracking separates the information model (IM) from the UI so that the UI discovers dependencies upon
the IM and automatically updates itself. In this first installment, you will find out how to construct the IM for a dependency-tracking
application. In Part 2, you will see how to build the UI on top of the IM. In Part 3, you will use dependency to solve some
common application problems. Part 1 lays the groundwork for automatic dependency tracking. You won't actually see automatic
dependency tracking in action until Part 2, but your patience will be rewarded.
Throughout the series we will develop Nebula, a drag-and-drop application for visually designing computer networks. With this
application, network designers can model a physical network, determine addressing, and run simulations to discover problems.
Admittedly, this is a complex example, but as you will see by the end of the series, automatic dependency tracking makes even
complex problems quite manageable.
Read the whole series on automatic dependency tracking:
Let's start at the beginning: a properly designed information model.
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- Download the source code that accompanies this article as a zip file
http://www.javaworld.com/jw-08-2001/automatic/jw-0817-automatic.zip
- Download the source code that accompanies this article as a jar file
http://www.javaworld.com/javaworld/jw-08-2001/automatic/jw-0817-automatic.jar
- Design PatternsElements of Reusable Object-Oriented Software, by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides (Addison-Wesley, 1995; ISBN 0201633612) is the definitive reference
for reusable software solutions. It discusses, among others, the Observer pattern, in which observers register for notification
of changes to subjects. Though automatic dependency tracking is an alternative to the Observer pattern, the mechanism relies
upon other patterns found in the book
http://www.amazon.com/exec/obidos/ASIN/0201633612/javaworld
- Suchitra Gupta has written a thorough review of various update mechanisms, and discusses the Event Notifier (or Publish/Subscribe)
pattern in detail
http://www.users.qwest.net/~hartkopf/notifier/
- The Microsoft Foundation Classes for Visual C++ contains a Document/View architecture for routing hints to all views of a
given document
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_cdocument.3a3a.updateallviews.asp
- In Object-Oriented Software Construction, Second Edition (Prentice Hall, 1997; ISBN 0136291554), Bertrand Meyer defines and discusses many of the concepts central to the theory and
practice of object-oriented software construction. Central to his thesis is the abstract data type (ADT)
http://www.amazon.com/exec/obidos/ASIN/0136291554/javaworld
- In "Build User Interfaces for Object-Oriented Systems, Part 2The Visual-Proxy Architecture" (JavaWorld, September 1999), Allen Holub describes the visual proxy mechanism, in which objects in the abstraction layer (his information
model) create presentation layer objects to represent themselves
http://www.javaworld.com/javaworld/jw-09-1999/jw-09-toolbox.html
- Browse our Topical Index for more articles on Applied Java: http://www.javaworld.com/channel_content/jw-applied-index.shtml
- Read more JavaWorld articles on User Interface Design: http://www.javaworld.com/channel_content/jw-ui-index.shtml
- Sign up for JavaWorld's free weekly email newsletters
http://www.idg.net/jw-subscribe
- You'll find a wealth of IT-related articles from our sister publications at IDG.net