advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
Download the sample code for this article.
Partners & Affiliates
advertisement
advertisement
Average Rating: 4/5 | Rate this item | 1 user has rated this item.
 Print Print
 
Monitoring and Enforcing Design Dependencies with Verifydesign
Verifydesign lets you codify a design in XML and run compile-time checks to notify developers of dependencies that break the design specifications. 

advertisement
lthough software and architectural reuse has been a constant drumbeat in the technical press for many years, it's still common to see code and designs that violate many principles of reuse. For example, how many software systems have you seen that are similar to the diagram in Figure 1? Or when trying to reuse code, you find an exisiting component with functionality you need (Component E), but you also find it impossible to reuse the component because it depends on Component C—which your new system doesn't need. You might add that component only to find that, in turn, Component C depends upon Component A.


Such interdependencies are still typical of many software projects today. Of course, such code isn't generally produced on purpose. A team typically lays out the architecture, then starts coding up the system. As they code, bad dependencies unintentionally slip in—sometimes that just happens—and the team often doesn't even discover such unwanted dependencies until later in the development cycle.

 
Figure 1. A Typical Software System: The figure illustrates the tangled relationships between components in many software systems.
 
Figure 2. An Ideal Software System: Note the linear relationship path between components in this application.
Now a new open-source tool called "Verifydesign" is available to monitor code to help prevent unwanted dependencies. Figure 2 shows a more appetizing set of relationships between software components. In Figure 2, the yellow bars represent the APIs. Components communicate only through these APIs. I intentionally drew lines in Figure 1 from the middle of a component to the middle of another component because that's the reality of most software systems today. Figure 1 emphasizes that many software systems don't bother communicating through the API, but instead go directly to the middle of a component as shown. In contrast, Figure 2 shows a design without the circular dependencies of Figure 1.

VerifyDesign lets you define the dependencies between software components. Some examples from Figure 2 might be:

  • Implementation of Component A depends on Component B's API
  • Implementation of Component A depends on Component C's API
  • Implementation of Component A depends on Component D's API
In the rest of this article, I will detail how the Verifydesign tool works to define and enforce dependencies.

How Teams use the Verifydesign Tool
Here's an example system that uses Verifydesign. The system consists of a phone and a client that controls the phone. The client depends on the phone's API. The phone's API has no dependencies, and the phone's implementation must depend only on the phone's API. Along the way, I'll present this information as if to a new developer who doesn't yet understand the design. The code will intentionally violate the design dependency rules to demonstrate Verifydesign's real power—adherence to an actual design. This desired design is what I call the "package design" (as opposed to the actually implemented design).

First, I urge you to download the code, so you can follow along. The download contains a file named verifydesign/packagedesign/bldfiles/design.xml, shown below:

<design>
   <!--The phone's api is defined to depend on nothing -->
   <package name="phoneApi" package="biz.xsoftware.api.phone"/>
   <!--The phone's implementation obviously implements 
       and depends on the api -->
   <package name="phoneImpl" package="biz.xsoftware.impl.phone">
     <depends>phoneApi</depends>
   </package>
 
Figure 3. Enforced Relationships: The figure shows a graphical view of the enforced relationships between packages as declared in the design.xml file.
<!--The client is defined to depend on the phone's api (not the phone's implementation) --> <package name="client" package="biz.xsoftware.impl.client"> <depends>phoneApi</depends> </package> </design>
As a first step, run the build and make sure the code you downloaded doesn't violate the design. To run the build, go to the verifydesign/packagedesign directory and run the command:

   ant --f bldfiles/build.xml 
You should see a BUILD SUCCESSFUL message. The XML file shown above contains some basic rules about dependencies that are allowed in the source code. The file declares five packages. A graphical picture of the above "package design" would look like Figure 3.

The diagram in Figure 3 represents each declared package in the file as a box, with each arrow representing a dependency. These are the only dependencies allowed in the Java code. What we're trying to achieve is an environment where (for example) when a programmer changes the code such that client depended on PhoneImpl, the developer should be warned. Now, I'll walk you through Verifydesign's capabilities in detail. For this demonstration, pretend you don't know anything about the design, and we'll wreak some havoc on the system so you can see how VerifyDesign can help.

  Next Page: Finding Unwanted Dependencies


Page 1: IntroductionPage 3: Adding New Packages
Page 2: Finding Unwanted DependenciesPage 4: Using Verifydesign on Legacy Systems
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About


JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES