Datasheet

29
Chapter 1: Gathering What You Need to Develop BlackBerry Apps
Thus, your application can exist in the App World in multiple forms. For
example, if you intend for your app to be used only by those users who have
accelerometers in their BlackBerry devices, you can restrict your app to an
OS 4.7-only zone, and no other device will be able to install it. Note: If you
want your app to run on all devices but also take advantage of accelerometers
when running on a Storm, you have to develop two versions of your app: one
for Storm devices and then one for all the rest.
The key point is that these two different applications only constitute one
app submission to the App World, so you’re only paying for one submission
instead of two. Chapter 12 goes over the details you need to know about the
App World, and your app’s life there.
Programming defensively
Your application hopefully will be used by tens of thousands of people
worldwide. When that happens, each user becomes a stress test for your
app. These users will inadvertently discover ways of breaking your
application — causing unforeseen consequences to occur — that you never
thought of. Your users will be your next major challenge.
Users follow a bell curve in terms of their use of your app. Most will behave
exactly as you expect, following a “happy path” of operation where they
never encounter shortcomings in your app and never try to make the app
do something incorrect. But a small faction of users either intentionally or
unintentionally drives your app into a situation it’s not prepared to handle. If
you’re working for a large organization with a Quality Assurance department,
a great many of these situations can be discovered and resolved before your
code hits the outside world. If you’re a solo entrepreneur, the burden falls on
your shoulders.
Most abnormal situations are a result of invalid user input. This specific cause
can be eliminated through the use of fixed-input entry fields: UI elements that
restrict user input to particular data types or specific values. In addition, your
app should “sanitize” the data that users can provide as input, to make sure
that nothing bad gets inside your app to wreak havoc.
For instance, your app may want users to enter a date value, perhaps for a
birthday reminder. You could use a simple text-editing component, such as
an EditField, for users to select and start typing in a date. But you would
then have to make sure that what they enter is actually a real date — this
could be any of the following:
09/01/10
September 1, 2010
2010-09-01
05_467114-ch01.indd 2905_467114-ch01.indd 29 8/30/10 1:05 PM8/30/10 1:05 PM