ARTICLE ARCHIVE
XP marks the spot: Developing for Windows XP

What challenges does the next version of Windows pose for software developers? Angus Kidman plunges into the world of side-by-side assemblies, prefetching and high-density displays.

Published in IT Wire,
August 31 2001

Barring major legal action or an unexpected typhoon in Seattle, Windows XP will make its official appearance on October 25. While consumers fret over XP's memory requirements -- is 64 megabytes really enough? -- developers face a different challenge. For them, the task ahead is re-engineering their existing applications to prevent them crashing when running under XP, and perhaps to take advantage of some of its new features as well.

But is it worth the effort? And what's the best way to proceed? IT Wire spoke with Kyle Marsh, a developer working with the Windows XP evangelism team, during Microsoft's recent Tech Ed conference in Melbourne, and gathered together this selection of handy hints for prospective Windows XP developers.

Marsh is confident that the transition to XP will be worthwhile for most code jockeys. "The Windows XP architecture will take us a long way towards solving some pressing development issues," he said. The process is also not as complicated as previous migrations. "The biggest shift was 3.11 to 95," Marsh said, that being the fundamental shift from 16-bit to 32-bit code. "This is nowhere near as difficult." That said, Marsh acknowledges that "no new OS release makes developers' lives easier".

Eventually, many of the requirements discussed below will be tied into the 'Certified for Windows XP' logo program run by Microsoft. Even those changes that aren't officially required for the program may be worth pursuing, as they'll make migration onto future Windows platforms more straightforward, and eliminate problems with up-and-coming hardware platforms.

Just before we leave the consumer behind, Marsh is definitely in the 'more memory is good' camp. "Adding memory is the easiest way to improve intensive application performance," he said.

Use side-by-side assemblies
The single most obvious change for developers in XP is the implementation of 'side-by-side' assemblies, designed to eliminate the previous compatibility problems with dynamic link libraries (DLLs). Minor changes to commonly used DLLs such as ComCtl32.dll often resulted in applications failing, causing hard-to-trace bugs. "Obviously if we can get out of DLL hell, everybody's happy," Marsh said.

XP eliminates that problem by allowing applications to specify which versions of common DLLs they require. This is done in an XML file known as the 'manifest'. Older applications without a manifest will default to older versions of common interface DLLs; newer applications will be able to use the extra features in XP DLLs, such as visual styles. "What we're trying to get to is an isolated application," Marsh said.

Work with the new visual styles
Windows XP introduces a choice of visual styles, offering either the 'classic' Windows 95 look or the new XP approach. To access these, you'll need to include a manifest referring to the new DLLs, and then use the theme manager APIs to draw all visible controls in your application. Older software will maintain the classic look unless you upgrade it. "The default is you won't get the new styles. We have to have you test them," Marsh said.

Minimise your use of DLLs
Despite the introduction of side-by-side assemblies, Microsoft is campaigning to avoid a proliferation of DLLs in general. "We think fewer, larger DLLs perform better than smaller DLLs," said Marsh. "You should think about the number of DLLs needed."

A related hint is to make sure that you keep your compiled apps as small as possible. "Your footprint is a huge element of performance," Marsh said. "Always compile for size. In the end, it's the hard drive that kills your performance."

Remember applications launch faster
Design changes in Windows XP mean that applications will generally launch faster. "The big win here is on the memory and the disk prefetching [placing data in memory before it's actually required]," Marsh explained. As a result, elements that you have previously incorporated, such as splash screens, may no longer be necessary.

Take advantage of fast user switching
Windows XP implements fast user switching, which means that multiple users can have concurrent sessions running on a single machine. While handy for users, developers need to be aware that this changes the assumptions they can make about the state of the machine.

This is especially important when designing dialogues to indicate a process has finished. Playing sounds to indicate this is also a no-no, as it won't make sense if a different user is on the machine and hears the sound, but can't access the app that played it.

Another waiting-game tip: the default Windows dialogues now include Internet locations such as 'My Web Folders'. As a result, you may need to add extra error checking for systems that don't maintain a live connection.

Registry rules
Try to minimise use of the registry (Microsoft is adopting this approach across the .NET framework). When you do use the registry to store data, use values rather than individual keys unless there's no way around it.

Design for high-density displays
While it's not strictly a Windows XP requirement, Microsoft is encouraging developers to start coding with displays other than the typical 96dpi screen found on most monitors and notebooks. As higher-resolution displays become more common, this will be an important requirement (existing apps will still work at a procedural level, but will often be hard to read and may be rendered effectively inoperable). Redesigning code for high-density displays will also make it easier to meet accessibility requirements for visually impaired users.

Learn to communicate
Because XP has tools such as Messenger built in, it's much simpler to incorporate facilities such as messaging or videoconferencing. "It's very easy to add real-time communications to your applications, especially if you know the context in which you might talk to somebody," Marsh said. "It's just a few lines of code."

Admittedly, there are still some restrictions. "The limit for XP as a client is you must know the machine name or the IP address," Marsh said. For corporate applications, that's not an unreasonable requirement.

Take part in the logo program
This is perhaps more to do with promotion than pure development, but worth noting nonetheless. Certified software will feature in the Windows Product Guide, a Microsoft-run listing of XP-specific software that is directly accessible from the XP Start menu. To qualify, you'll need to use the Windows Installer and follow a number of other guidelines, including many listed here. The Windows XP logo program will be self-certifying, making it cheaper than previously. "If you really take advantage of the OS, we'd like to help sell your product," said Marsh.

BACK TO THE GUSWORLD WRITING PAGE