Friday, April 17, 2009

10 Rules for Writing Safety Critical Code

Gerard Holzmann's Ten Rules for Writing Safety Critical Code specifies rules for developing safety critical code in C, rules that improve software reliability and testability. More detailed descriptions can be found in the June 2006 Issue of IEEE Computer, which can be found here. For me, there are other programming languages out there who may be better suited for safety-critical (and real-time) systems, languages like Ada or Erlang. I believe that one important aspect of such systems is to make sure that the routines invoked will take a deterministic amount of time to complete.

Thursday, April 16, 2009

Android and Symbian on Netbooks

Corresponding to a report by In-Stat, HP is pushing Android into Netbooks. From the Information Alert:

"This solution bypasses the huge memory, storage, and graphics requirements associated with Windows and lowers hardware cost, as well as the software cost. It also addresses the changes in the market. Over the past decade, we've seen two megatrends in electronics – mobility and the Internet. As content and applications migrate to the Internet, these trends will change to mobile Internet and Internet ubiquity. Adopting Android or another open source OS with a custom UI and good browser technology addresses these changes in many specific applications and usage models."

I do agree with the article, and I believe that Android will have a bigger impact on non-smartphone devices (such as Netbooks) than it will have on smartphones.

Symbian is not behind on all this. According to this article, the S60 5th Edition runs on a "off the shelf Intel Atom based motherboard", which means directly on the x86 hardware. The difference is that Symbian runs on x86, while Android runs on ARM.

Visualizing Sorting Algorithms

Here is a website where you can view animations of different sorting algorithms that shows you how they operate, how the preconditions affect the performance of the algorithms, and which one performs better than the other under certain conditions and input sizes. You can also view the source code behind each algorithm. If you are looking for other 'animations', you can find them here, here, here, and here.

Wednesday, April 15, 2009

Constant Interfaces

A constant interface is one that contains no methods, only static final fields, each declaring a constant. Below is an example:
public interface UniversalConstants {
//Speed of light in m/s
static final int SPEED_OF_LIGHT = 299792458;

//Newtonian constant of gravitation in m^3 * kg^-1 * s^-2
static final double GRAVITATION = 6.6742867e-11;

There were times in the past that I've used such interfaces in classes that needed the constants. This is a poor use of interfaces. An interface serves as a type that tells you what a class that implements that interface can do with an instance of it. There is nothing of this kind when using constant interfaces. How can we avoid this? (At least) In two ways. One, define the constants inside your class, if you feel that there is a strong relationship between those constants and you class. The other way is to use a utility class that cannot be instantiated, like below:
public final class UniversalConstants {
//Speed of light in m/s
public static final int SPEED_OF_LIGHT = 299792458;

//Newtonian constant of gravitation in m^3 * kg^-1 * s^-2
public static final double GRAVITATION = 6.6742867e-11;

When using these constants from within your own class, you can add a static import declaration and you're done!

Android 1.5 (Cupcake) Highlights

Android 1.5 introduces new and exciting features. Here are some that I find important:
  • Accelerometer-based application rotations
  • Faster Camera start-up and image capture
  • Much faster acquisition of GPS location (powered by SUPL AGPS)
  • Smoother page scrolling in Browser
  • Video recording and playback
  • Bluetooth: stereo bluetooth support (A2DP and AVCRP profiles), auto-pairing, improved handsfree experience
  • Browser: copy 'n paste in browser, search within a page
  • Framework for easier background/UI thread interaction
  • Raw audio recording and playback APIs
  • Support for using speech recognition libraries via Intent
  • LocationManager - Applications can get location change updates via Intent
  • Broadcast Intent for app update install succeeded - for smoother app upgrade experience
For a complete list of features, visit the android developers web page.