Smartphones aren’t getting any smarter

As an Android and mobile web developer, I feel compelled asking people I know or meet a lot of questions about their phones. One trend I’ve been seeing is feedback that smartphones, themselves, aren’t really getting any smarter. The ironman/crossfit marathon to add new features at warp speed has left behind a trail of cool phones that have some fundamental issues. So, I’m going to take a look at some of these here.

To put things in perspective, at Google I/O 2013, Sundar Pichai announced that there have now been 900 million Android activations world-wide to date. That’s not including iPhone activations, of course. But, Yeow, that’s a lot of phones! So, let’s look at some things that haven’t improved much. It’s almost like Newton’s Third Law of Motion can be applied to smartphones: while some things improve, other things must take a back seat.

Security. I can say this with certainty – I have yet to see or hear about a smartphone advertisement that says something such as “we’re striving to make this phone the most secure phone yet.” One thing is clear that Apple’s app vetting process helps reduce the level of malware compared to Google Play. Sure I understand that nothing is 100% secure, but the operating system vendors and the handset vendors could at least talk about it.  And, why don’t smartphones come with built-in, optimized versions of virus checkers and anti-malware tools like Windows PCs and laptops?

Most people’s lives could be seriously disrupted by the data stored on your typical smartphone, and we lose these and leave them behind accidentally by the thousands, and we inadvertently install malware.

Case in point – do a search on Google or bing using the term “smartphone security”, and see how many articles are published by the major phone vendors about security and securing your phone. The top result is by the FCC about their Smartphone Security Checker.

Restoring an Android phone. If you reset your droid or buy a new one, restoring everything back to the way it was and in it’s exact place, well…a very manual process. This is not very user friendly. Hey Android vendors, you should take a lesson from Apple on this one.

Display brightness and energy consumption. Phone displays appear to continue to be the “number one” draw on battery life. I’ve started to think most (many?) like their screens really bright. I mean realllly bright. It’s funny, I keep mine pretty dim to squeeze as much life out of the battery as possible, and I’ve lost count of the number of times people have said something like “how can even you see what you are doing??”

GPS energy consumption. My Garmin GPS lasts over 17 hours of continuous usage with two AA batteries. The battery on a typical smartphone has much greater storage capacity, but in actual field tests I’ve killed smartphone batteries in as little as 4 -5 hours of continuous GPS usage. GPS used wrong is a huge draw on the devices battery. Sure, a smartphone is doing a lot more work than a typical, single purpose GPS. But, my point is why hasn’t GPS battery consumption improved over five generations of smartphones? Those of us who build GPS-based native and web apps have to jump through hoops to optimize battery life in applications that do more than take a snapshot of the users current location. Some of the algorithms we write should simply be built-in to the firmware.

Charging times. Now I admit this varies from phone-to-phone but it’s still not very fast in general. I know I have said before that many people are never more than 10 feet from a charger, but for those of us who aren’t that attentive to charging I can say charging times can be an issue. For example, my iPad (okay it’s more of a tablet than a smartphone) is the slowest charging device on the planet compared to my original Google Ion which charged from dead to full in about an hour and a half. Sure, I understand there is a huge difference in battery size, but my point still stands. The cute, itty-bitty charger for iPad is way under-powered for the needs of charging a larger battery.  And, maybe some people are okay with that?

Planned Obsolescence.  This one is totally on Android. I’ve lost track of the number of Android phones that I have sitting around that have been rendered obsolete because the handset manufacturer provided one or maybe even two OS updates to the phone, and then they stopped. They become obsolete in the sense that some apps don’t run on older versions of the operating system. Sure, the upgrades are enticing (better camera, more memory, faster processors, etc. etc.) but what if someone doesn’t want or need to upgrade?

This may become more of an issue for people as some carriers are stopping their subsidies of phones and pushing users to carry the cost of a new phone directly. And new phones can give you sticker shock. If you have to pony up $350 – $600 for that new phone and all it’s advertised features, you might not be inclined to upgrade phones as often as you used to.

Wrap-up. So, I’ve written a mish-mash of different things that should be improved for both Android and iPhone. What I’d really like to see, and it probably won’t happen, is for Android, Apple and Microsoft to take a step back from the feature/functionality marathon and work on some fundamental issues to build an even stronger foundation for the next generation phones.

 

Share
Tags: , , , , , , ,
Posted in Android, iPhone | No Comments »

Mac vs PC: A developers perspective

I’ve been a PC person since the beginning of time, and I recently decided to switch to a Macbook Pro.  I’ve gotten questions recently from folks about how I like it. So, this post summarizes some of my thoughts and discussions on the Mac vs PC debate reframed into a software developer perspective – and without all the hype. I think it’s safe to say I’m a power user and my needs go well beyond a typical consumer. So my ratings reflect that mind set.

Chassis: Rating A++++

While this has nothing to do with functionality, per se, and everything to do with aesthetics I’ve never had a more beautifully built ‘machine’. The brushed aluminum looks great and the device feels rock solid. It doesn’t creak like old wooden stairs when you hold it like a dinner platter while carrying it from meeting to meeting. The construction of Windows laptops I’ve used, and some of them were considered top-of-the-line, mostly pale in comparison. It’s like comparing a brand new Porsche fresh off the factory line with all it’s power and state-of-the-art construction to my beloved but campy ’95 Camry.

Speed: Rating A

I have had this discussion with a number of colleagues. The speed from the Macbook Pro comes mainly from the SSD (Solid State Drive). I’ve seen Windows laptops with SSDs perform just as admirably when doing CPU intensive work such as large software builds.

Screen: Rating A++++

The screen on the Macbook Pro is…wow. In all fairness there are some really awesome screens on the latest generation of Windows machines too.

Easy of Use: Rating B

Now’s were things get controversial. Let me explain. I believe that Mac’s are just as easy to use for the 80% of things most every-day consumers use them for as Windows machines. But, remember I’m a power user. So, once you step off the cliff into the 20% of things that aren’t intuitive I think Windows machines are much easier to manage because it’s more GUI oriented. Let me give you an example.

Setting up Apache, creating virtual directories and ongoing management of the web server for newbies isn’t exactly intuitive. I’m not talking about cobbling together the pieces needed to host simple HTML web pages; I’m talking about hardcore web server abuse. Granted my bash skills have gotten rusty after years of using Windows, and yes some things are very easy to quickly do in a terminal window, but having lots of GUI interfaces are nice when you are feeling lazy. Some days you just don’t feel like recalling complex and arcane sequences to manipulate your github account. Case in point for GUIs, I’d say compare the easy-of-use of SourceTree to using the command line when doing intermediate to advanced github manipulation. When I started using my Mac I would have loved to have something similar to IIS for manipulating Apache.

Stability: Rating A-

I do want to point out that my Mac has locked up and I’ve had other miscellaneous hiccups with various parts of the operating system that required a reboot or a force quit. Some applications have given me fits for example, I’ve had to manually kill off Charles debugging proxy quite a few times when it went hog wild and chewed up vast chunks of my available CPU. Having used numerous Windows laptops and untold number of Windows-based applications, I haven’t seen anything like that in years. Granted these issues on my Mac have been few and far between, but they did happen…and it got my attention.

Attaching to other devices: A+

The bane of Windows was trying to connect to various devices and finding the right device driver from various manufactures is always lots of fun. Connecting to smartphones has never been easier for me than on my Mac. The only trouble I ever had was connecting to a network printer. That turned out to be counter-intuitive to a newbie and took several calls to tech support and two days to figure out. I’d say connecting to network printers, which is a common task in the typical work environment, is much easier with Windows.

Using with Corporate Software: C

This experience hasn’t been so great overall. Using a Mac on a PC-based network has its challenges, such as connecting to network printers. I’ve also noticed that the Mac versions of PC software typically have less functionality. I don’t know why this is the case. For example, for some strange reason the Mac version of PowerPoint has less functionality for drawing shapes, and it has a very limited selection of built-in clip art. Go figure. Why do I use PowerPoint? Because sometimes you have to collaborate on presentations with folks who use Windows machines, or maybe you have to share your presentation and the vast majority of users have Windows machines.

Battery Life: Rating A

I seriously debated with myself on including this. It’s so subjective but it always, always comes up in conversations. At what I’d consider a medium level of CPU usage, I can eke out about 4’ish hours of battery life. There, I said it. What I mean by medium level of usage is doing build after build using an IDE, or doing numerous intensive page refreshes while banging out a web app as opposed to hanging out and doing general internet surfing or using a Word processor.

But, to be honest it’s rare these days during anyone’s normal, everyday routine that you aren’t within close proximity to a power outlet. You can even get power adapters for use in your own car if you want. The exceptions are when you travel and then power can get scarce at some Airports, certain conferences, some particularly crowed coffee shops, and certain types of public transportation. Some airlines have graciously even gone to providing 110V outlets. I mean, short of those exceptions I rarely have need to exercise the full life of my laptops battery prowess.

Noise level: Rating A+

I’ll end this post on talking about fan noise. 99% of the time my Mac doesn’t emit any sounds other than the tappity-click-clack of my poking at the keyboard. I love it. All my other Windows laptops have had fans that often were noisy enough to make it hard to hear during meetings. I remember being shushed a couple of times during particularly intense meetings when the virus checker kicked off and caused the CPU to generate enough heat that the associated fan level noise exceeded that of an F-18 in full afterburner. The only time my Mac’s fan starts to get noticeable is when something I’m doing continuously drives the CPU past 30% for an extended period of time. Examples of this include video conference calls and some video based web pages.

Conclusion

There are certainly many more things I could discuss, but I felt these were the highlights. Overall my Macbook Pro has been a very nice machine and I’ll give it an A rating. It’s the nicest looking laptop I’ve ever used. But looks aside, it has proven to be a fairly stable and fast performer. Access to everyday functionality is easy enough to figure out. As a newbie Mac power user, some of the advanced settings are counter intuitive and some seem needlessly arcane. I’m glad I’ve been able to actually try out a Mac after all these years of hearing about them.

Share
Tags: , ,
Posted in Apple | No Comments »

Hack4Colorado 2013 – Civic Hackathon

Do you live in Colorado and want to have fun playing with code, learn new APIs and datasets, and generally testing your coding “skillz” while under pressure and competing with other hotshot developers for prizes? If you answered “yes”, then I strongly recommend you check out the opportunities at the Hack4Colorado event which takes place on the weekend of May 31st. This event is part of a national civic hacking day where other States, Counties and Cities around the country are doing exactly the same thing.

The concept is simple. These events help promote open government data that can be used within applications that you build to solve everyday problems. So, these organizations provide you with cool data sets to choose from and you have fun building an application around it. Ideas include find the nearest rent-a-bike location, explore local hiking trails and so much more.

Full disclosure, Esri has also graciously offered to provide bountiful cash (yes, cash!) prizes. Other sponsors are offering Rokus, Kinects, and even Big Wheels (yes you also heard that right!). I even have an application in mind that I might try to build when I’m not helping other folks out.

What do you think? Hopefully I’ll see you there.

Share
Tags: , ,
Posted in Conferences | No Comments »

Easy enums for custom JavaScript libraries

There’s a ton of information on the internet related to the best way to create JavaScript enums. This post is different in that it focuses on using enums that are immutable and cannot be changed within your own custom libraries.

The challenge with enum usage in JavaScript is global variable leakage can accidentally cause unexpected changes within your application, especially in cases of large, complex applications that may involve your own JavaScript libraries along-side 3rd party libraries. Global variable leakage means two variables can potentially have the same name, and this may not cause an error. Good debuggers help to avoid this problem by using jslint. But, if someone else is using your libraries then you can’t depend on them using best practices. So, variable leakage can cause unexplainable/unpredictable problems and create hard to track bugs. What we need is a coding pattern to protect enums so that we can guarantee that we always get the value expected.

As of today, JavaScript doesn’t have a universally accepted, built-in cross-browser solution for guaranteeing that specific variables can be made immutable. In other words, if we create a statement var BLUE = “blue” there is no way to enforce that something elsewhere in an application, or code that someone else wrote that is running the same application cannot ever change the value of BLUE.

In comparison, strongly typed languages such as C# and Java let you declare constants. If you accidentally try to change them in your code you get a compiler error that prevents the application from running. The compile-time checking can help prevent bugs in your code later on. Here are several examples from Java and C#:

 final int RADIUS = 1000; //Java
 const int RADIUS = 1000; //C#

So here we go. I’ll use six use cases to illustrate a variety of ways to make certain your enums are immutable. This list is not designed to be all inclusive, its intent is to demonstrate patterns that you can use to learn more about JavaScript enums. You can try these out using the following jsfiddle.

USE CASE 1 – Basic public enum function with no namespace protection. This use cases offers the least amount of protection against global variable leakage. I’d only expect to see this type of enum in very small, stand-alone applications.

function basicEnum() {
    var values = {
         BLACK: '#000000',
         RED: '#FF0000',
         GREEN: '#00FF00'
    }

    return values;
}

console.log("test0 " + basicEnum().BLACK); //test0 #000000

USE CASE 2 – Basic public enum that uses an internal, privately scoped namespace in which to define the enum object. This use case offers slightly more protection than Use Case 1, but the public function itself is still not protected within the global namespace. It’s possible there could be two functions with the same name “colorEnum”. And, the larger the application gets the higher probability there is of having accidental name duplication.

function colorEnum() {
    var values = values || {}
    values.colorEnum = {
         BLACK: '#000000',
         RED: '#FF0000',
         GREEN: '#00FF00'
      };

      return values;
};

console.log("test1 " + colorEnum().colorEnum.GREEN); //test1 #00FF00

USE CASE 3 – Public enum with no namespace protection using an anonymous function expression to define the enum. This is a variation of Use Case 2 showing you can define multiple categories of enums. And, like Use Case 2 it still offers zero public/global namespace protection. I’m using the terms public and global to mean the same thing.

DoSomething = (function(){

    var constValues = constValues || {}
    constValues.color = {"BLACK" : "#000000" }
    constValues.error = {"ERROR_TIMEOUT" : "Connection Timeout" }
    return constValues;
});

console.log("test2 " + DoSomething().color.BLACK); //test2 #000000
console.log("test3 " + DoSomething().error.ERROR_TIMEOUT); //test3 Connection Timeout

USE CASE 4 – Public enum with namespace protection using an anonymous function expression and internal (private) namespaces to differentiate multiple categories of custom enum objects. This use case starts to offer better protection against global variable leakage by wrapping the public function in a namespace.

var my_test = my_test || {}
my_test.DoSomething = (function(){

    var constValues = constValues || {}
    constValues.color = {
        "BLACK" : "#000000",
        "RED" : "#FF0000"
    }
    constValues.error = {
        "ERROR_TIMEOUT" : "Connection Timeout",
        "ERROR_FAULT" : "Connection problem"
    }
    return constValues;
});

console.log("test4 " + my_test.DoSomething().color.BLACK); //test4 #000000
console.log("test5 " + my_test.DoSomething().error.ERROR_TIMEOUT); //test5 Connection Timeout

USE CASE 5 – Namespace protected public anonymous function expression along with an internally (private) scoped function that defines the enum. This is a variation of Use Case 5 showing how to use switch/case statements along with a privately scoped function that are all wrapped inside the anonymous function.

var my_second_test = my_second_test || {};
my_second_test.DoSomething = (function(val){

    var color;

    switch(val)
    {
        case 1:
            color = basicEnum().BLACK;
            break;
        case 2:
            color = basicEnum().RED;
            break;
        case 3:
            color = basicEnum().GREEN;
            break;
    }

    function basicEnum() {
        var values = {
             BLACK: '#000000',
             RED: '#FF0000',
             GREEN: '#00FF00'
        }

        return values;
    }

    return color;
});

console.log("test6 " + my_second_test.DoSomething(2)); //test6 #FF0000

USE CASE 6 – This Use Case shows placing a privately scoped anonymous function expression defining the enum inside a public anonymous function expression, and finally accessed through another prototyped anonymous function expression. Yikes, that was a lot of technical mumbo-jumbo verbiage, right?! It also offers several tests to validate if the enum is immutable or not.

var my_third_test = my_third_test || {};
my_third_test.DoSomething = (function(){

    this.basicEnum = (function() {
        var values = {
             BLACK: '#000000',
             RED: '#FF0000',
             GREEN: '#00FF00'
        }

        return values;
    });

});

my_third_test.DoSomething.prototype.findColor = (function(val){
    var color;

    switch(val)
    {
        case 1:
            color = this.basicEnum().BLACK;
            break;
        case 2:
            color = this.basicEnum().RED;
            break;
        case 3:
            color = this.basicEnum().GREEN;
            break;
    }

    return color;
});

var myColor = new my_third_test.DoSomething();

console.log("test7 " + myColor.findColor(3)); //test7 #00FF00

//The enum properties cannot be changed
myColor.basicEnum().BLACK = "test";

console.log("test8 " + myColor.basicEnum().BLACK); //test8 #000000

try{
    //test that basicEnum() is immutable
    myColor.basicEnum() = "test"; //Throws ERROR!
}
catch(err){
    console.log("test9 " + err);
    //test9 ReferenceError: Invalid left-hand side in assignment
}

Conclusion. So that’s all there is to it. Hopefully these examples help to not only demonstrate some patterns to protect your data, but also give you ideas for saving time while building larger applications.

Reference.

JSFiddle project

Share
Tags: , ,
Posted in JavaScript | No Comments »

jQuery Mobile – Setting full content width

Here are some hints to help get all of your jQuery content stretched to the full width of your mobile browser screen regardless of screen size or orientation. These techniques have been tested on jQuery 1.7.x, jQuery 2.0 and jQuery mobile 1.3.1.

Lets start with a look at the minimum required CSS:

html,body,div[data-role ="page"], div[data-role="content"] {
    height: 100%;
    width: 100%;
    margin: 0px;
    padding: 0px;
}

Problem – Using the minimum CSS above, leaves a spacer on the top and left hand sides of the app, and the right hand border and/or bottom border disappears. I noticed the right hand margin extends approximately 9 to 15 pixels (or greater depending on device) beyond the visible view. I verified this behavior on Android 4.1 native browser and Chrome 26, as well as on iPad 3 using Safari and Chrome 25.

Solution – set certain CSS width properties as shown below. This solution has been tested on Android 4.1 native and Chome 26, Android 2.3.2 native, and on iPad Safari and Chrome 25. Just a bit of a warning that if displayed on a desktop browser you will see vertical scrollbars. But, you should be detecting the different between mobile and desktop anyway, right!

Note: this solution doesn’t address the problem with content height, it only looks at width. So, yes, you will notice that the height of my sample is off the page.


<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7,IE=9">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

    <title>jQuery Test</title>

    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />

    <script type="text/javascript" src="http://code.jquery.com/jquery-2.0.0.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.js"></script>
<style>
        html,body, div[data-role ="page"] {
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
        }

         .ui-content{
            height: 100%;
            width: 100%;
            margin: 0px;
            padding: 0px;
            border-style: solid;
            border-color: chartreuse;
            border-width: 5px;
        }

        #map {
            height: 100%;
            width: 100%;
            padding: 0px;
            border-style: solid;
            border-color: crimson;
            border-width: 10px;
        }
</style>
</head>

<body>

<div data-role="page" id="page1" >

    <div data-role="content">
        <div id="map"</div>
    </div>

</div>
</body>

References

Determining the dimensions of an [HTML] element

Check HTML5 Browser Height and Width using Canvas

[Modified April 26, 2013 - fixed code bug]

Share
Tags: , , ,
Posted in JavaScript, jQuery | 1 Comment »

Smartphone devs, yes SD card speed matters!

If you want to get the highest performance out of your SD cards then read on. The purpose of this article is to raise awareness and spark your curiosity about SD card performance considerations.

Micro SD Class 2

Many developers I talk to aren’t aware that the read/write speeds of SD memory cards can have a significant affect on performance. This is especially true if you are moving around lots of data between a smartphone and the SD card. The good news is there is quite a bit of information out there to help you maximize performance, and a lot of it comes from high-end, camera aficionados believe it or not.

The most common feedback I get is developers typically buy cards with the most capacity at the lowest price. Depending on what you are doing, cheapest and slower isn’t always better. With little bit of research your read/write performance could get significantly better.

To start with there are four common speed classes: 2, 4, 6 and 10 and they represent an approximate minimum performance rating. You can find this number on the front of your card:

  • Class 2 ~ 2 Mbytes/sec
  • Class 4 ~ 4 Mbytes/sec
  • Class 6 ~ 6 Mbytes/sec
  • Class 10 ~ 10 Mbytes/sec

Read/write performance to your phones SD card really depends on HOW your application reads and writes data. You may have to do some testing to find out what works best. It depends on the consideration of multiple factors including:

  • Typical file types (e.g. video vs. text vs. image, etc)
  • Average file or data transaction size
  • Percentage of reads to writes
  • Duty cycle (percentage of reads or writes over a fixed time period)
  • Usage pattern

Usage pattern deserves a bit more attention and really starts to tell the story of what your application does behind-the-scenes. I think the best way to describe it is through some common use cases:

  • Many small reads and writes to/from a local database.
  • Occasional small reads and writes to local database.
  • Occasional large reads from local database.
  • Occasional large reads and writes to/from local database.
  • Large read upon application startup and large write upon application shutdown.

Wikipedia has noted that speed can differ significantly depending on what you are writing to the card. The article notes that writing large files versus writing many small files has widely different affects on performance. I’d seen similar observations when I worked on ultra-high performance server systems. So, the concept still remains today and provides excellent hints on how to tweak every extra millisecond of user experience.

If you need maximum performance then consider reformatting or defragging your card on a regular basis. I know Windows disk defragmenter utilities work on most SD cards, not sure about Mac. I have also seen multiple articles talk about bigger capacity is better because of memory fragmentation. With memory fragmentation, the card speed starts to decrease over time as the data becomes more fragmented. It’s the same concept as when you “defrag” the hard drive on your laptop.

References

If you want to learn more here are some helpful links:

SD Association – Bus speed

SD Association – Speed Class

Wikipedia – Secure Digital (See Speed Class Rating section)

Does your camera need a fast SD card? (good insight into SD card speed)

Share
Tags: , , ,
Posted in Mobile | No Comments »