Dr. Dobb's Journal - November 2007 - (Page 52) d11jiri_p8db 9/11/07 12:55 PM Page 52 State of the Art REUSABLE ASSOCIATIONS This style of implementing associations, in some situations, prohibits derivation of the UML class diagram from the code automatically—additional information such as variable names, written documentation, or comments would have to be included. Today, you typically start with a UML class diagram describing classes and the associations among them (Figure 2). UML class diagrams are popular because they provide a network representation of a problem, which is difficult to understand without a picture, and because associations used in the UML diagram are more powerful than collections in existing class libraries. UML works with a number of different views, each using a different style of diagram. When we say “UML diagram” in this article, we refer to the most popular of these—the class diagram. If we could expand existing libraries such as STL or Java Collections to include associations, it would improve the existing software design methodology in several ways: • It would force us to think in more general terms—in associations instead of collections and individual references/pointers. • MDD code generators would be simpler because there would be a one-to-one match between the associations in the diagram and those in the code. • For the same reason, UML diagram generators would be easy to code and always safe to use. Collections deal with only two classes where one of them controls the other, while associations involve two or more cooperating classes that may know (and access) each other. Adding a collection requires an addition to the controlling class only but adding an association may require additions to several participating classes (Listing Two). The Java implementation would be identical, except for references instead of pointers. We find it logical and convenient to use the association names, such as nets or blockNets, for the inserted member. When an application class participates in several associations (such as Net in Listing Two), several members are inserted, one for each association. Once popular, pointer-based data structures have been neglected and are completely missing from existing class libraries. Like associations, intrusive data structures (IDS) require coordinated insertion of members into participating classes. For example, collection masters in Listing One may be implemented as an intrusive linked list: class ChipLib { Master *masters; }; class Master { Master *next; }; PC l. st ge y oo nd on sl e t ki e l uou ar an Th n tw m nti of . . co sed s of . ti ry ver to ad e his th in -lint 8.0 for C/C++ #include class R Presents { public: Bug of the int k, depth; R() :k(0), depth(0) {} Month #1772 const R& operator=( const R & r ) { Wacknia is attempting to if( this != &r ) simulate the recording industry { k = r.k; depth = r.depth+1; } where a copy of a recording R return r; is less faithful than the } original. Member depth is }; meant to record the degree of int main() imperfection. But to her { surprise this program is R r1, r2, r3; printing "1 1 0" rather than r1 = r2 = r3; the expected "2 1 0". What's printf( "%d %d %d\n", going on? Visit our web site at r1.depth, r2.depth, r3.depth ); } www.gimpel.com Plus Our Traditional C/C++ Warnings: Uninitialized variables, inherited non-virtual destructors, strong type mismatches,ill-formed macros, inadvertent name-hiding, suspicious expressions, etc., etc. Full Language Support for ANSI/ISO C and C++. PC-lint for C/C++ will catch this and many other bugs. It will analyze a mixed suite of C and C++ modules to uncover bugs, glitches, quirks and inconsistencies. Not your Grandpa’s lint: PC-lint has introduced several spectacular and revolutionary innovations in the art of static program analysis. Taking clues from initializers, assignments, and conditionals, variable and member values are tracked, enabling reports on potential uses of null pointers and out-of-bounds subscripts. New with Version 8: Interfunction value tracking – Actual argument values are used to initialize parameters; return values are computed; a multipass operation (you control the number of passes) allows you to plumb the depths of function behavior to arbitrary levels. PC-lint for C/C++ Numerous compilers/ libraries supported. Runs on Windows, MS-DOS, and OS/2. $239 FlexeLint for C/C++ The same great product for other operating systems. Runs on all UNIX systems, VMS, mainframes, etc. Distributed in shrouded C source form. Call for pricing. 30 Day Money Back Guarantee G i m p e l S o f t wa r e Serving the C/C++ Community for 22 Years. CALL TODAY (610) 584-4261 Or FAX (610) 584-4266 www.gimpel.com PC-lint and FlexeLint are trademarks of Gimpel Software 52 Dr. Dobb’s Journal l www.ddj.com l November 2007 Besides being more efficient than arraybased collections (faster to traverse, smaller footprint), when such lists are implemented with rings instead of NULL ending lists, they provide effective runtime protection of data integrity. As demonstrated by the IN_CODE library (www.codefarms.com/products.htm), one-to-one, one-to-many, and many-tomany associations can be implemented in the intrusive style. On the other hand, all the IDS the authors know implement one association or another. Perhaps there are some IDS that are not associations, but for a library of generic associations, we should use a mechanism that would support any IDS as well. Structural design patterns are data structures that combine associations with http://www.gimpel.com http://www.codefarms.com/products.htm http://www.gimpel.com http://www.gimpel.com http://www.ddj.com
Table of Contents Feed for the Digital Edition of Dr. Dobb's Journal - November 2007 Contents Hmmmm Alia Vox Developer Diaries Developer’s Notebook Smart Compilers - But Smart Enough? Conversations Grid-Enabling Resource-Intensive Applications Distributed Computing: Windows and Linux Adobe AIR: Desktop/Web Convergence Transparency on Demand Reusable Associations Effective Concurrency The Agile Edge Swaine’s Flames Dr. Dobb's Journal - November 2007 Dr. Dobb's Journal - November 2007 - (Page Cover1) Dr. Dobb's Journal - November 2007 - (Page Cover2) Dr. Dobb's Journal - November 2007 - (Page 1) Dr. Dobb's Journal - November 2007 - (Page 2) Dr. Dobb's Journal - November 2007 - (Page 3) Dr. Dobb's Journal - November 2007 - Contents (Page 4) Dr. Dobb's Journal - November 2007 - Contents (Page 5) Dr. Dobb's Journal - November 2007 - Hmmmm (Page 6) Dr. Dobb's Journal - November 2007 - Hmmmm (Page 7) Dr. Dobb's Journal - November 2007 - Hmmmm (Page 8) Dr. Dobb's Journal - November 2007 - Hmmmm (Page 9) Dr. Dobb's Journal - November 2007 - Alia Vox (Page 10) Dr. Dobb's Journal - November 2007 - Alia Vox (Page 11) Dr. Dobb's Journal - November 2007 - Developer Diaries (Page 12) Dr. Dobb's Journal - November 2007 - Developer Diaries (Page 13) Dr. Dobb's Journal - November 2007 - Developer’s Notebook (Page 14) Dr. Dobb's Journal - November 2007 - Developer’s Notebook (Page 15) Dr. Dobb's Journal - November 2007 - Smart Compilers - But Smart Enough? (Page 16) Dr. Dobb's Journal - November 2007 - Smart Compilers - But Smart Enough? (Page 17) Dr. Dobb's Journal - November 2007 - Smart Compilers - But Smart Enough? (Page 18) Dr. Dobb's Journal - November 2007 - Smart Compilers - But Smart Enough? (Page 19) Dr. Dobb's Journal - November 2007 - Conversations (Page 20) Dr. Dobb's Journal - November 2007 - Conversations (Page 21) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 22) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 23) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 24) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 25) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 26) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 27) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 28) Dr. Dobb's Journal - November 2007 - Grid-Enabling Resource-Intensive Applications (Page 29) Dr. Dobb's Journal - November 2007 - Distributed Computing: Windows and Linux (Page 30) Dr. Dobb's Journal - November 2007 - Distributed Computing: Windows and Linux (Page 31) Dr. Dobb's Journal - November 2007 - Distributed Computing: Windows and Linux (Page 32) Dr. Dobb's Journal - November 2007 - Distributed Computing: Windows and Linux (Page 33) Dr. Dobb's Journal - November 2007 - Distributed Computing: Windows and Linux (Page 34) Dr. Dobb's Journal - November 2007 - Distributed Computing: Windows and Linux (Page 35) Dr. Dobb's Journal - November 2007 - Adobe AIR: Desktop/Web Convergence (Page 36) Dr. Dobb's Journal - November 2007 - Adobe AIR: Desktop/Web Convergence (Page 37) Dr. Dobb's Journal - November 2007 - Adobe AIR: Desktop/Web Convergence (Page 38) Dr. Dobb's Journal - November 2007 - Adobe AIR: Desktop/Web Convergence (Page 39) Dr. Dobb's Journal - November 2007 - Adobe AIR: Desktop/Web Convergence (Page 40) Dr. Dobb's Journal - November 2007 - Adobe AIR: Desktop/Web Convergence (Page 41) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 42) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 43) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 44) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 45) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 46) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 47) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 48) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 49) Dr. Dobb's Journal - November 2007 - Transparency on Demand (Page 50) Dr. Dobb's Journal - November 2007 - Reusable Associations (Page 51) Dr. Dobb's Journal - November 2007 - Reusable Associations (Page 52) Dr. Dobb's Journal - November 2007 - Reusable Associations (Page 53) Dr. Dobb's Journal - November 2007 - Reusable Associations (Page 54) Dr. Dobb's Journal - November 2007 - Reusable Associations (Page 55) Dr. Dobb's Journal - November 2007 - Reusable Associations (Page 56) Dr. Dobb's Journal - November 2007 - Effective Concurrency (Page 57) Dr. Dobb's Journal - November 2007 - Effective Concurrency (Page 58) Dr. Dobb's Journal - November 2007 - Effective Concurrency (Page 59) Dr. Dobb's Journal - November 2007 - The Agile Edge (Page 60) Dr. Dobb's Journal - November 2007 - The Agile Edge (Page 61) Dr. Dobb's Journal - November 2007 - The Agile Edge (Page 62) Dr. Dobb's Journal - November 2007 - The Agile Edge (Page 63) Dr. Dobb's Journal - November 2007 - Swaine’s Flames (Page 64) Dr. Dobb's Journal - November 2007 - Swaine’s Flames (Page Cover3) Dr. Dobb's Journal - November 2007 - Swaine’s Flames (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.