May 28, 2008

Windows Mobile: Communicating with the Outside World

n last month’s DevX special report, I showed you how you can develop for the Windows Mobile platform using the .NET Compact Framework. Now, you’ll expand on those concepts and learn how you to explore the various communication options available on this platform so that your applications can connect to

Validate an XML Document Only When a DTD Exists

Learn how to use the DOMImplementationDS and DOMConfiguration classes to validate an XML document only when a DTD document can be found: DOMImplementationLS DOMiLS=null;? //get a LSParser object LSParser LSP=DOMiLS.createLSParser( DOMImplementationLS.MODE_SYNCHRONOUS, “”); //get a DOMConfiguration object DOMConfiguration DOMc=LSP.getDomConfig(); //use validate-if-schema option if(DOMc.canSetParameter(“validate-if-schema”,true)) DOMc.setParameter(“validate-if-schema”,true); else System.out.println(“Error…”);?

Concatenating Strings

When you’re concatenating only a few strings, it’s faster to add them than to use StringBuilder. Suppose you want to decompile the following code: string a = “a”;string b = “b”;string c = “c”;string d = “d”;string s;s = a + b + c + d; You will see that

Get into the Habit of Preventing Bugs in if Statements

Unintentionally using = instead of == in an if statement can prove a nasty source of bugs. In the following code, myFunc is called if i equals 0: if (i==0) myFunc(i); Now suppose that in your haste to meet a deadline, you accidentally wrote: if (i=0) myFunc(i); This code would