Toolbox

XML Comments, Online Payments, and More

Scott Mitchell

Contents

Quickly Add XML Comments to Your Visual Studio Projects
Accept Online Credit Card Payments
Improve Your Programming Experience in Visual Studio
A Guide to Developing Data-Driven Applications

Quickly Add XML Comments to Your Visual Studio Projects

The Microsoft® .NET Framework simplifies the task of documenting classes, methods, properties, and events through XML comments. XML comments are special XML tags embedded within source code comments that provide metadata about classes and their members. During compilation, this metadata is converted into a stand-alone XML file by Visual Studio®, which can then be converted into help files using tools like the Microsoft Sandcastle project.

GhostDoc Generates XML Comments Automatically

GhostDoc Generates XML Comments Automatically(Click the image for a larger view)

While XML comments assist in automating the conversion of source code comments into a rich help document, the comment text must still be written, a job many developers find mind-numbing and laborious. Why not use automation to expedite the creation of these comments? That’s exactly what GhostDoc 1.9.5 attempts to accomplish.

GhostDoc is a free Visual Studio add-in, created by Roland Weigelt, that assists in authoring XML comments. Once GhostDoc has been installed, using it to auto-generate XML comments is as simple as point and click. For example, to add XML comments to a method, simply right-click within the method and choose the "Document this" option from the context menu. GhostDoc will then automatically generate the XML comment text for the method based on its type, parameters, name, and other contextual information.

If you’re generating documentation for a property or method that uses a type in the .NET Framework, GhostDoc will use the documentation that Microsoft has already written for that type. Assuming you use Pascal casing or camel casing, GhostDoc can break apart the name into words and analyze those individual words to generate the documentation. All of the documentation logic is handled by GhostDoc’s generation rules. The built-in rules can be customized and new ones can be added. These rules can be exported for use on other machines as well.

Except for the simplest members, you can’t rely on GhostDoc to write your XML comments for you completely. GhostDoc’s auto-generated comments are suggestions and should be reviewed by a developer. Regardless, GhostDoc serves as a good first stab at documentation and is a great time-saver.

Price: Free.

www.roland-weigelt.de/ghostdoc

Accept Online Credit Card Payments

During my career as a developer, I’ve often considered taking some application or component I’ve created and selling it to other developers. But figuring out how to process online payments always seemed complex.

Today, virtually all online transactions are paid for using a credit or debit card, and to accept these types of payments you need two things: a merchant account from a financial institution (such as your neighborhood bank or an online entity like PayPal), and a payment gateway. A merchant account allows payments to be collected from another bank account or credit card. A payment gateway is a system that manages the electronic processing of a payment.

Many companies provide payment gateway services. One of the easiest I’ve found to use is Authorize.NET. Once you’ve created an account with Authorize.NET, you can collect payment information from your customers either through the Authorize.NET Web site or from your own Web site. With the first approach, customers are sent to Authorize .NET’s Web site as the final step in placing an order. There they enter their payment information and are charged the specified amount. Authorize.NET then redirects them back to your Web site.

With the second approach, a customer’s payment information is entered directly from your Web site and then sent to Authorize.NET’s servers behind the scenes as an XML payload via a secure HTTP request. This XML data interchange can be done programmatically with a few lines of code in an ASP.NET page. Alternatively, there are a variety of third-party shopping cart products that provide support for Authorize.NET.

Regardless of how the customer’s payment information is collected, Authorize.NET interfaces with your merchant account and the customer’s credit or debit card account, billing the customer and crediting your account. Amazingly, this entire process typically takes just a few seconds.

Authorize.NET provides both address verification and card code verification to help deter credit card fraud. And Authorize.NET can be configured to handle recurring payments.

Keep in mind that Authorize.NET is just the payment gateway. You also need a merchant account, which carries its own setup, monthly, and transaction fees. Many financial institutions charge in the neighborhood of $100 for setup, $30 or so as a monthly fee, and another 2.0-3.0% plus $0.05-$0.50 fee per transaction.

Price: $149.00 setup, $20.00 monthly, and $0.10 per transaction.

www.authorize.net

Improve Your Programming Experience in Visual Studio

With each new version, Visual Studio adds more wizards, features, and tools that aid in developer productivity and efficacy. While the enhancements built in to each new version are helpful, there are a host of other tools that can be used to increase productivity, as evidenced by the robust Visual Studio add-in market. These add-ins provide even more features geared toward assisting developers write, refactor, and test code.

One such Visual Studio add-in is ReSharper 2.5 by JetBrains, which offers intelligent error highlighting with quick-fix options, extended refactoring support, customizable code formatting, unit testing, NAnt and MSBuild script editing, and a variety of tools for quickly searching and navigating through the types and files of a Visual Studio project. The features I found most handy were the quick-fixes and the navigation and search options. Quick-fixes appear as a lightbulb icon next to a line of code where ReSharper has detected a warning or error. For example, if you forget to perform a type cast, ReSharper notifies you via a lightbulb icon with a quick-fix option to automatically inject the appropriate cast.

ReSharper Notifies You about Quick-Fixes via a Lightbulb Icon

ReSharper Notifies You about Quick-Fixes via a Lightbulb Icon(Click the image for a larger view)

The navigation and search capabilities of ReSharper are ideal for large projects where there are many types and files. The Navigate from Here feature allows you to quickly jump to a variable or type’s declaration or base class. Moreover, it can list any inheritors as well as all places where the variable or type is used in the project. A Find Results window makes it easy to search the project for a particular type. The File Structure window shows the types and members of the current file. From the File Structure window you can reorder the types or members in the file and quickly jump from the window to a particular member in the file.

Note that the Visual Studio .NET 2003 version of ReSharper works only with C# code. However, the Visual Studio 2005 version does offer some Visual Basic® features, though not all of those that are available for C# developers. ReSharper also includes some features for editing ASP.NET Web pages.

Price: $249 for a single-user license.

www.jetbrains.com/resharper

A Guide to Developing Data-Driven Applications

When I first started programming data-driven Visual Basic applications back in the late 1990s, a coworker encouraged me to pick up a copy of William R. Vaughn’s Hitchhiker’s Guide to Visual Basic and SQL Server, a tome whose heft and thickness earned it the nickname "the doorstop." Throughout the 90s, Vaughn published six editions of his popular Guide. After a nine-year hiatus he has released the seventh edition, written with Peter Blackburn, and renamed Hitchhiker’s Guide to Visual Studio and SQL Server (Addison-Wesley, 2007).

Like the previous editions, the seventh provides detailed and thorough discussions on important topics, from installation of SQL Server™ 2005 to T-SQL basics to creating and working with data through a .NET application. The book starts with a look at application architectures, noting different data access technologies and comparing and contrasting the different versions of SQL Server 2005. Next, Vaughn steps the reader through installing SQL Server 2005 and addresses security and management issues. This is followed by a look at SQL essentials: SELECT, INSERT, UPDATE, and DELETE statements; views; UDFs; TRIGGERs; stored procedures; database design; normalization; data and relational integrity; and so on.

Hitchhiker’s Guide to Visual Studio and SQL Server is split pretty evenly between discussions of SQL Server-specific topics and working with data using Visual Studio. The Visual Studio-related material include accessing databases through the IDE, using ADO.NET to programmatically work with data, building Typed DataSets, and techniques for modeling database entities as objects within an application architecture.

Vaughn’s knowledge and accessible writing style make this book a must-have for .NET developers creating data-driven applications. As with his past books, Vaughn’s code examples are all in Visual Basic, but that shouldn’t dissuade C# developers as the real value of this book lies in the concepts and architectural advice, not in cut and paste code samples.

Price: $59.99.

www.aw-bc.com

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

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@4guysfrom­rolla.com or via his blog at www.ScottOnWriting.NET.