spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / awxml2 / 1 To page 1To page 2To page 3To page 4To page 5To page 6current page
[previous]

Oracle DBA (IL)
Next Step Systems
US-IL-Lombard

Justtechjobs.com Post A Job | Post A Resume
Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans


Using XML with Legacy Business Applications: Chapter 1

Additional C++ Considerations

A few words are in order regarding my approach to using C++. In particular, I want to point out handling of strings, exceptions, and constants.

The final ISO and ANSI C++ standard has extremely useful string classes (at last!). These are much easier to use and less prone to runtime exceptions than old C-style char arrays, char pointers, and the C string library. However, these string classes are still not universally supported “out of the box” by many major C++ compilers. They weren’t supported natively by Visual C++ 6.0, which I’m using for this book. Even though some add-on open source and proprietary class libraries do support these classes, many developers use only what is standard from the compiler vendor. In addition, a lot of the legacy C++ code currently in production doesn’t use these string classes. Finally, neither MSXML nor the Apache Xerces C++ API that is its best alternative use the ISO/ANSI string classes. MSXML uses COM strings (as we’ll discuss in Chapter 2 and Appendix C), and the Xerces C++ API uses its own XML char class. They both support conversions to and from char arrays, not ISO/ANSI strings. So, for all these reasons I’m sticking with char arrays, char pointers, and the old C string library.

In the early days of C++ compilers, throwing exceptions for common runtime errors was discouraged because exception handling wasn’t very efficient. The general view is that compilers have gotten a lot more efficient in this regard. However, a lot of the standard C++ library functions still use status codes or return values rather than throw exceptions for every little thing the way that Java does. For this reason I generally use the approach of returning status values from functions rather than throwing exceptions.

Regarding constants, some programmers believe that using #define rather than const to define constants is “evil” [Cline 2002]. I certainly prefer the Java style of defining constant class members. However, I found it extremely awkward to define constants that could be shared across classes using this approach with Visual C++ 6.0. There may be better ways to do it with compilers that provide better support for the final ISO/ANSI C++ standard. I’m sure there are people who are more clever about C++ programming than I am. At any rate, I’ve taken the easy way out in this book and used old C style #defines.

The general picture you should draw from this discussion is that the C++ code presented here does not necessarily represent current best practices in C++ coding. It instead represents “good” practices (I hope) as of the mid-1990s. However, I’m not really too concerned about that. If your legacy C++ applications are very old, they probably don’t reflect current best practices either. Your code may look very similar to mine. On the other hand, if you are using more up-to-date compilers and following current best practices (for example, using the string class instead of char arrays), by all means keep doing what you’re doing and don’t regress. You should, however, still be able to follow my code and update the techniques to your current best practices as appropriate.

~ How You Can Use the Utilities and Code

Welcome to the wonderful world of copyrights and licenses. All the utilities and code developed in this book are open source. Their copyrights are owned by the good people at Addison-Wesley, but you can use the utilities and code under the terms of the GNU General Public License (GPL), Version 2, included as Appendix A. This is the same license under which Linus Torvalds makes the Linux operating system available. I hope you and your organization will feel comfortable using this stuff without having to get the lawyers involved.

In the final analysis the terms of the GPL take precedence, but here is what I intend.

The synopsis above applies to everyone. Here are my intentions for more specific groups of readers and users.

In short, I hope that you benefit indirectly from the programs and the source code and that you feel free to share them with others. However, don’t look to me for free warranty support, and don’t try to make money directly from this work.

(Oh, and just to make sure I haven’t forgotten anything: Everything I just said applies to the binaries and the source code but not to the book itself. It, too, is copyrighted by Addison-Wesley, but we want everyone to pay for copies. We have to get something out of this!)

~ References

Cafiero, Bill. 2002. Remarks while leading a panel discussion at the semimonthly meeting of the Dallas/Fort Worth Electronic Commerce Forum, July 18, in Irving, Texas.
Caine, S., and E. K. Gordon. 1975. “PDL—a Tool for Software Design.” In the American Federation of Information Processing Societies’ Proceedings of the 1975 National Computer Conference, Anaheim, CA, 19–22 May 1975. Montvale, NJ: AFIPS Press, pp. 271–276. Available online at http://www.cfg.com/ pdl81/pdlpaper.html, accessed July 11, 2002.
Cline, Marshall. 2002. “C++ FAQ Lite.” Available online at http://www.atd.ucar.edu/software/c++faq/newbie.html#faq-29.7, accessed March 27, 2003.
Shaw, Mary, and David Garlan. 1996. Software Architecture—Perspectives on an Emerging Discipline. Upper Saddle River, NJ: Prentice Hall.
W3C (World Wide Web Consortium). 2002. Document Object Model main page. Available online at http://www.w3.org/DOM/, accessed July 10, 2002.
Apache Software Foundation: http://www.apache.org
Essential XML Quick Reference, by Aaron Skonnard and Martin Gudgin (Boston, MA: Addison-Wesley, 2002). I don’t directly recommend very many other books in this book, but this is one I suggest without reservation. If you deal with XML on any technical basis at all, this book needs to be in your collection.
Microsoft’s XML Resources: http://msdn.microsoft.com/xml
Sun Microsystem’s Java Technology and XML: http://java.sun.com/xml World Wide Web Consortium: http://www.w3.org The XML Cover Pages: http://xml.coverpages.org

home / programming / awxml2 / 1 To page 1To page 2To page 3To page 4To page 5To page 6current page
[previous]


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger

Created: March 11, 2003
Revised: January 1, 2004

URL: http://webreference.com/programming/awxml2/