Editor's Note
Best Practices


Whew, what a month. As we worked on this super-fabulous issue, we've simultaneously been packing everything in the office for the move to our fancy new digs a few blocks away in the heart of Midtown Manhattan. For the most part, this has gone smoothly—although we just found out we're losing our classy 212 phone numbers for one of those lame new area codes, 646. 212 is the country's best area code. Its very mention invokes images of Swingin' New York at its finest in the mid-1970s. The air was redolent of Disco Fever, blackouts, riots, fiscal insolvency, and finally, Ed Koch. 212 says, "I've been through it all, and I'm still here." When you get a call on the second line, flashing a 212 on your caller ID, you say "I'm gonna put you on hold, Mom, this could be opportunity calling!" But when a 646 calls? "I don't recognize the number—probably a collection agency looking for my Saturn loan payment. I ain't answering that!"

So as you can see, we made the mistake of packing away our Editor's Note idea book, and we can't figure out which of the 4,215 moving boxes it's tucked away in. It's probably under a stack of Ashton-Tate demo disks we're sure will be a collector's item someday. One thing we do have on our minds (which have also been packed for shipping), is the not-entirely-new, but still vital, topic of best practices in programming.


When we solicited feedback at Tech•Ed this year, many readers told us that they wanted to see more discussion of best practices in the magazine. Best practices can be a bit of a tricky concept at times. There's not always one "right" way to get a task done, especially in computer programming, a creative art that masquerades as a science. Of course, design patterns are one way that the developer community attempts to reach consensus on the right way to do discrete tasks. But the right way to do something is necessarily driven by circumstance.

For example, is there always one right way to sort a list? Sometimes you just want a simple alphabetical sort of a set of strings. But other times, you might want to sort objects by certain properties, or even do advanced percentage hits on text lookups. You're not going to be doing a simple bubble sort when you build a relevancy-based search engine.

When we work on an article, we have it reviewed by technical experts to make sure that we're providing the right best practices advice to readers. Of course, sometimes what's considered "right" can change—when a new product or API is released, the best way to search through an XML file might also change, for example.

In the early days, Microsoft would often publish a bunch of code samples to demonstrate the use of a particular API. Since these samples were designed to highlight the way to call a specific API, rather than taking the complete sample's workings into account, they didn't always reflect the best way of getting a job done. So you might have a call that showed how to use a particular SQL call, even though there might be a better method (like a stored procedure) to accomplish the same result. There were times when multiple samples could be internally contradictory in their presentation.

Realizing the potential for error this could cause, Microsoft has dedicated a lot of effort to developing proven architectures and best practices, and the fruits of this labor are evident on the Patterns and Practices Web site (see http://www.microsoft.com/resources/practices). One interesting new release is "Improving Web Application Security: Threats and Countermeasures". Using threat modeling, which evaluates appropriate countermeasures to security threats, the article helps you to create threat-resilient ASP.NET apps through a series of best practice recommendations.

We take best practices and security seriously here. If you see something in our magazine that you don't think is a best practice, we want you to let us know. Drop us a line (mmeditor@microsoft.com) and tell us how you'd do it better. Selected letters might be discussed in future issues. But not until we've unpacked all these boxes and the area code thing sinks in, at least.

—J.T.

IntelliSense, JScript, Microsoft, MSDN, Outlook, PivotTable, PowerPoint, Visual Basic, Visual C++, Visual J++, Visual Studio, Windows, Windows NT, and Win32 are registered trademarks of Microsoft Corporation. Other trademarks or tradenames mentioned herein are the property of their respective owners.

MSDN Magazine does not make any representation or warranty, express or implied with respect to any code or other information herein. MSDN Magazine disclaims any liability whatsoever for any use of such code or other information.

© 2007 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.