Ways to Develop for DevicesQuite a few technologies can be used to build applications for mobile devices. Much like desktop computers, the two primary models for application development are the server-based Web application approach and the smart-client approach. This book specifically concerns itself with smart-client applications for mobile devices, but for comparison it is worth having a brief overview of both application models for mobile devices. Server-Based Applications for Mobile DevicesServer-based applications are commonly referred to as "browser applications." They offer a great deal of flexibility. Attractively, they require no "on-device footprint" other than the presence of a generic mobile browser application on the device. The downside of this approach is that like other Web-based applications, mobile Web applications require a continual server connection and do not offer the richness and responsiveness of an on-device solution. The connectivity requirement is important to consider because unlike desktop computers mobile devices frequently go in and out of connectivity while their users are roaming around in the physical unwired world. However, if your application only needs to run when the user is connected and you want to target the largest range of devices, it is certainly worth considering a mobile Web-based solution. Note Many technology choices exist for supporting Web-application development targeting mobile devices. In addition to Microsoft ASP.NET''''''''s mobile controls, other Web-application technologies also support application development targeting mobile devices. These offer their own strategies for making Web applications geared toward mobile devices. If there is a popular Web-development technology you are using, chances are that there is a mobile device targeting extension available for it. Microsoft''''''''s technology for Web applications is called ASP.NET (Active Server Pages .NET). ASP.NET offers ASP.NET "mobile controls" for targeting mobile devices. Visual Studio .NET 2003 enables developers to build ASP.NET mobile device applications. Figure 1.1 shows the new project dialog in Visual Studio with the Mobile Web Application option selected. Figure 1.1. Beginning a new ASP.NET mobile Web application.[View full size image] ![]() Creating and designing a mobile Web application works much in the same way as creating and designing Web applications targeted at desktop Web browsers, with the following major differences: Design surface You are provided with a design surface that is specifically mobile device oriented with a simplified and streamlined control layout paradigm suitable for mobile applications. Device-targeted controls Instead of the norma146 set of controls, you are provided with a set of Mobile Web Forms controls to work with. These controls are specifically designed to render properly for a wide range of devices. Also offered are some controls specific to mobile devices, such as PhoneCall control. Rendered markup language At runtime, the Mobile Web Forms controls run on the server can generate Wireless Markup Language (WML), Compac153 (cHTML), o151 depending on the capabilities supported by the requesting device''''''''s browser. The server-side runtime takes on the burden of determining what the best display experience is for the mobile device interacting with it based on information the mobile Web browser submits with its request. Out of the box, the ASP.NET Mobile Web application technology supports a wide range of devices. Support for new device types can be added by Microsoft, device manufacturers, or end developers wanting to target a device type not yet supported by the framework. To access mobile Web applications, a device needs to have a capable mobile browser application present. There are many kinds of mobile browsers, the most common being the previously mentioned WML, cHTML, an138 browsers. Most modern smart phones come with some kind of Web browser technology installed. You can find a great deal more information on ASP.NET mobile applications in the online documentation. (The "Mobile" section of [http://www.asp.net] is a great place to start.) Smart-Client Mobile ApplicationsThis book focuses on software engineering for smart-client mobile applications. When you decide that your mobile-device application will work best as a rich client application, you have another basic decision to make. You need to decide which client-side technology to use. Will the application be written in native code or will you use a managed code solution? Both have benefits and drawbacks. Native CodeNative code development is usually done in C or C++. Native code is useful when you need the absolute maximum performance from a system or need low-level access to the hardware. However, native code has some significant drawbacks as well, including the following: Native code development is less productive than working with managed code. Because you are working at a lower level of abstraction, you will spend more time coding. Native code is processor dependent. When you compile to native code, you are generating instructions specific to the microprocessor you are targeting. This means that if you want to target more than one processor family, you must compile and deploy several versions of your application: This can also be true for different processors in the same processor family. For example, there are several different variants of the very popular ARM chip design that require different native compilers. Native code needs to be stress tested more than managed code. Working in native code means managing your own memory and other resources. Experience has shown that it is very difficult if not impossible to build a "perfect application." Almost invariably, some memory or other system resource is occasionally left unreleased in complex systems. Over time even small memory or other resource leaks that occur in repetitive code can strain the finite resources on a device. Many cell phones are never turned off. Many PDAs have instant-on features that keep applications running or in memory even when the device is switched off. With respect to memory leaks, mobile devices behave more like servers than desktop applications because mobile devices are often left on continuously. If you are leaking memory, you will eventually cause the system to become unresponsive or unstable. Native code development on devices requires an extra amount of diligence and 24/7 stress testing. |