RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Getting Started with Windows Mobile Development : Page 2

Although the Compact Framework is roughly one-third the size of the regular .NET Framework, it provides all of the requisite functionality to create powerful mobile applications.

Mobile Data
Mobile data differs from desktop applications mainly by:

  • Form factor
  • Memory restrictions
  • Processor speed
  • Bandwidth
  • Disconnected nature
Form factor is probably the most serious restriction in the world of mobile development. Mobile screen sizes run the gamut, from 2 x 3 inches up to 5 x 7 inches, resolutions from 240 x 320 pixels up to 640 x 480 pixels, and shapes from square to vertical or horizontal rectangles.

When designing a UI for a mobile application, you must consider the restrictions on space and plan accordingly. There are a number of issues that you face when designing forms for the mobile device. I will tackle these at length in the section dealing with compact controls later in this article.

Memory restrictions are another design factor. On mobile devices, memory is measured in megabytes, not gigabytes. While you can use mini plug-in cards to increase storage space, those don't increase the amount of memory available to programs. Because of the limited resources, you don't want to hold lots of data in memory, because that leaves little for system use. Mobile operating systems will shut down programs running in the background to provide resources to the foreground application.

Processor speed requires you to be cognizant of the time operations and database queries take. Device manufacturers are aware of the need for speed, and are pushing chip manufacturers to release faster and faster processors. PPCs being released later this year will use the newest 700 MHz processors.

Bandwidth is smaller than cabled systems or internal networks, so data access, in today's world, is slower than desktops and laptops. While great strides are being made, the technology is still on the cutting edge, and you will have to wait until the infrastructure catches up to the technology.

The disconnected nature of the data also presents some challenges. SQLme provides a number of ways to manage data on the mobile device: Remote Data Access, Merge Replication, and a new service called Microsoft Access Database Synchronizer. These capabilities let you move data to/from the mobile device; however, these services are not compatible with SQL Server Express editions.

All in all, it is fairly simple to work around these limitations by using good simple design and efficient data retrieval mechanisms.

Visual Studio Integration
Compact Framework development is integrated directly into Visual Studio. With this coupling, you can develop your application, control emulators, test SQL replication, write unit tests, and cradle a real device to test synchronization using WMDC or ActiveSync.

You have two options when writing/testing your mobile application:

  1. The actual device
  2. An emulator
Developing with the actual device is a common practice when you want to test program speed, ease of physical use, etc. However, it can be an expensive proposition if you want to test many devices.

Emulators are virtual devices built on the same hardware platform as the original device. Emulators make it much easier to develop for many different devices with varying form factors and capabilities. Microsoft provides a number of emulators, with both the Windows Mobile 5.0 SDK and Windows Mobile 6 SDK, giving you the capability to test multiple form factors and device requirements.

Most mobile technology manufacturers today also provide emulators for their devices to aid in your development effort. So if you need a specific emulator, the Treo 750 for example, you can usually download it from the manufacturer's web site.

Mobile Development in Visual Studio
You create your mobile application projects in the same way that you create regular desktop applications: From the File menu choose "New" and then choose "Project." Next, select a Smart Device Project (see Figure 1). You indicate the project name at the bottom and set the target Compact Framework edition using the dropdown list in the upper portion of the screen. Clicking OK on this screen leads to a subsequent form where you choose the target project type (see Figure 2). Visual Studio will then create your solution and add a default program and form.

Figure 1. Selecting a Device: The figure illustrates smart device project selection in Visual Studio 2008.
Figure 2. Select Project Type: Visual Studio gives you a number of options when selecting the type of project for mobile development.

Rename the form and program to give them meaningful names. Now you can build your solution in the same way you normally would with a desktop application. As you need class libraries or other forms, you simply right-click the solution or project and add the desired item.

The best practice for normal application design is to use a three-tier approach: a UI layer, a business layer, and a data layer. It is common practice in application development to separate these specific application functionalities into individual classes. Even if you intend to use the mobile application as a web services consumer, or use the same back-end classes as existing web or desktop/laptop applications, the three-tier approach still applies.

However, the mobile orders application described in this article uses only two tiers. Because the application uses strongly-typed datasets and the table adapters included with them, it doesn't make sense to have another data layer with duplicate method calls just to separate the functionality. The mobile orders program will have a UI layer and a business layer.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date