Toolbox

Code Generation, A Charting Component, and More

Scott Mitchell

Contents

Save Time with Code Generation
Build Snazzy Charts Quickly and Easily
Turn Images into Icons
The Bookshelf

Developers have a number of tools at their disposal, but which of these components do you really need to complete your project? Each month we'll analyze the latest software and books to see if they merit inclusion in your toolbox.

Save Time with Code Generation

Last week your boss handed you the technical specs for your company's latest and greatest data-driven application. Over the past several days you've spent countless hours meticulously crafting the database tables, and the myriad of C# or Visual Basic® business objects needed to model these database entities in code. Great! You're now ready to start working on the fun stuff, the business logic and the front-end.

Your enthusiasm quickly wanes when you receive an e-mail from your boss informing you that the specs weren't as rock solid as he had thought: some of the database tables need to be removed, some new tables need to be added, and many others require one or more new fields.

Anytime there's a low-level change to the system's data model, there's bound to be a lot of work to update the system to reflect the change. While changes to the back-end can radically affect the front-end portion of the application, much of the middle-tier architecture's changes are rather tedious and therefore ripe for automation. Why write the code yourself when a program can write it for you?

CodeSmith, by CodeSmith Tools, LLC, is a code generation tool that can help remove the tedium of any oft-repeated programming task through the use of templates. A template can be executed, which outputs text that contains the automated code, stored procedures, SQL scripts, or whatever else you customize the template for. A template in CodeSmith is composed of three parts: properties, source code that's executed at runtime, and a mix of static and dynamic text. Armed with this template you could create a business object for any database table with the click of a button.

CodeSmith

While you can write your own CodeSmith templates from scratch, a number of popular templates ship with the software. There's also an active user-driven template community available on CodeSmith's Web site where enthusiasts share their customized templates. CodeSmith also offers integrated Visual Studio® support, allowing template creation and code generation straight from the IDE. CodeSmith templates can also be executed from the command line, making it possible to integrate code generation within the build process.

Automated code generation works best if it's embraced as early as possible in a project. While you can create and customize templates to fit into an existing application, it might not be worth the time and effort if the application is fairly stable. If, however, you work on an ever-changing application or are beginning a new project, consider using CodeSmith to assist in churning out the application's tedious code.

Price: $299 for the Professional Version.

www.codesmithtools.com

Build Snazzy Charts Quickly and Easily

A picture is worth a thousand words, and nowhere is this more true than in reporting. While tables of numerical data may be interesting, nothing can replace the value of a well-designed, professional-looking chart. Pictorial representations of data better highlight trends and enable the viewer to more quickly grasp the "big picture."

In my experience I have found that charts should most definitely be provided, but only if they're done right. While charts can be constructed programmatically from the System.Drawing classes, crafting anything but the simplest of charts will likely eat away more time than forecast, and, even then, will likely look amateurish. In short, buy a quality charting component, and use it!

When evaluating a charting component, I look for three things:

Ease of Use How long does it take to go from nothing to a professional-looking chart?

How Well Does it Work with My Data My data may be in a database, an XML file, or a custom business object. How easy is it to get my data, in whatever form it may be, onto the charting surface?

Bells and Whistles What charts are available, can the end user interact with the chart, how easy is it to customize the colors, fonts, and appearance of the chart, and so on.

The charting component I'm particularly fond of is Dundas Charts, from Dundas Software, which meets and exceeds all three of my charting component criteria. With Dundas Charts I can go from nothing to a fully functional, impressive-looking chart in a matter of minutes. The wizard, which is fully integrated with Visual Studio, makes it easy to customize the chart's type and style settings. The object model allows you to bind any enumerable data source—DataSets, DataReaders, arrays, lists, and so on—to any one of a number of chart properties. Put these two features together and you can create the chart, customize its appearance, and bind it to data in a matter of minutes.

Dundas

What is especially impressive about Dundas Charts is the quality of the charts. A variety of attractive chart styles make it easy to create eye-pleasing charts, even for someone as artistically challenged as I am. Furthermore, there are plenty of bells and whistles with Dundas Charts. Want to make that chart 3D? Simply click a checkbox. Want to have the chart animated? That's another checkbox. Want to add a trend line, based on one of a number of statistical models? That's one line of code.

When displaying charts online, you can render the charts as image files (JPG, PNG, BMP, and so on), as Scalable Vector Graphics (SVG), or as a Macromedia Flash file. There's also support for image maps. All of the chart rendering is done server-side, so there's no dependencies required on the client (unless you render as SVG or Flash, in which case the browser must have the appropriate software installed).

While there is both an ASP.NET version and a Windows® Forms version, my experience has been solely with the ASP.NET version. Dundas Charts has made creating snazzy-looking charts an easy, fast, and fun task; highly recommended!

Price: $699 for the ASP.NET or Windows Forms Professional Version.

www.dundas.com

Turn Images into Icons

If you are a micro-ISV, operate as an independent consultant, or work in a small company, you likely don't have a full-time resource that you can tap to meet your graphic and icon needs. You may have an artistic friend or know a freelance graphic artist you can use when the need arises, but you hate to bug your friend, and that graphic artist isn't cheap. What's a graphically impaired developer to do?

If you simply need icons for your application, check out Frontbase Image to Icon (created by Frontbase, Ltd.). It is designed to do one thing—- take an existing image and convert it into an icon. You can now grab your logo or that image the graphics designer already whipped up, and convert it into an icon on your own.

Frontbase Image to Icon is a cinch to use. Simply select an image file—BMP, GIF, JPG, PNG, or other formats—- and you've got yourself an icon! You can specify the icon's dimensions and color depth, modify the icon's transparency pixel-by-pixel, and adjust the contrast, brightness, and colors of the resulting icon. Image to Icon also supports multiple images per icon file.

Frontbase Image to Icon is the perfect solution for the graphically challenged developer who needs to be able to quickly generate icons from existing image files.

Price: $19.95.

www.image2icon.com

The Bookshelf

If you're a hard-core .NET coder, you no doubt spend the majority of your day using Visual Studio. While most developers use Visual Studio as a means for writing and debugging code, the IDE offers much more functionality underneath the surface. You can monitor and tweak your servers, manage your database's structure and data, and integrate third-party software through the use of Add-Ins.

book

Visual Studio Hacks (O'Reilly, 2005), by James Avery, provides 100 quick lessons about Visual Studio. (Note: I authored five of the hacks.) The 100 hacks span a variety of useful topics, such as working with the editor, mastering debugging, customizing Visual Studio, and extending and enhancing Visual Studio through Add-Ins. One of my main concerns with this book was what version of Visual Studio it would focus on. Would it look solely at Visual Studio 2005 hacks, or would there be information for developers still using previous versions? The good news is that the book is fairly balanced. Most of the hacks discussed apply to both Visual Studio .NET 2003 and Visual Studio 2005, with any version-related differences noted in the text.

Due to the vast amount of time I spend using Visual Studio, what interested me most was information that could improve my efficiency with the IDE. There are two chapters in Visual Studio Hacks that achieved this aim: Speed Hacks and Customizing Visual Studio.

The Speed Hacks chapter includes 15 hacks for decreasing the time it takes to get Visual Studio to do what you want. This includes tips on creating and using macros, quickly creating connection strings, and inserting commonly used code automatically. I found this chapter the most useful of all the 13 in the book. Customizing Visual Studio also proved helpful, as it shows how to tailor the Visual Studio environment to match your personality and work style.

The book wasn't written to be an end-all reference for using Visual Studio. If you are new to the IDE, or need to become an in-depth Visual Studio guru, there are better books available. If, however, you use Visual Studio on a regular basis and want some quick, interesting tips and tidbits of information on how to customize and get the most out of Visual Studio, this book is for you.

Price: $24.95, 500 pages.

www.oreilly.com

Send your questions and comments for Scott to  toolsmm@microsoft.com.

All prices were confirmed at press time and are subject to change.

Scott Mitchell, author of numerous books and founder of 4GuysFromRolla.com, is an MVP who has been working with Microsoft Web technologies since 1998. Scott is an independent consultant, trainer, and writer. Reach him at mitchell@4guysfromrolla.com or via his blog at ScottOnWriting.NET.