Jul 14 2012

Retweet June 2012

From time to time I just blast tweets about software development, project planning, team dynamics, or whatever else comes to mind. Here is a synopsis of recent tweets and rants. If you want to follow the conversation follow me at techknow and/or juixe.

Software Development

  • Software will rule the world.
  • Software will inherit the earth.
  • In the interwebs, beta is forever.
  • The future is written in code.
  • When you have no QA, everyone does QA.
  • I breakpoint for bugs.
  • Can’t say enough good things about jqPlot. It’s a great JavaScript charting library.
  • Search term that popped up on my blog’s analytics dashboard: programming languages are like girlfriends: the new one is better because *you* are better
  • I prefer “show me the source code” over “show me the money”
  • No simple change ever ends up being so simple.
  • Optimize for simplicity.
  • I remember when developing in JavaScript was cool, then when it wasn’t, then it was cool again, back to not, … fast forward to now.
  • How many licks does it take to get to the Tootsie Roll center of a Tootsie Pop? And … how many leaks does it take to crash your app?

Thought Leadership

  • Seek out silver bullets instead of reaching out to golden hammers.
  • The future is not in plastics, it’s in multicores.
  • Delegate and defer.
  • I have 99 problems and deferring and delegating them ain’t one.
  • Brainstorming the perfect storm.
  • “If you build it they will come” has been replaced with “test it, see if they will come, outsource it, and charge for it.”
  • No one starts out as an expert.
  • As a consumer, this is one concern I have with cloud/apps, that when they get updated you are forced into the upgrade no matter what.
  • If every piece of software is in the cloud, there will not be any legacy apps, everything will be in ‘beta’ or dead.
  • If you have writer’s block, put a stick of creative dynamite in it and light the fuse.
  • Disrupt all the things.
  • It is unfortunate that instead of finding the silver bullets people settle for a golden hammer.

Product Placement

  • Google started out as a search engine but when they searched for revenue the top result was advertising.
  • It has been reported that Google has applied for the TLD .lol in addition to .google and .youtube.
  • Is Google a gTLD squatter? They have applied for 98 domains including .app, .lol, .dad, .foo, …
  • The MLB and NFL should apply for .mlb and .nfl TLDs.
  • I’ll be happy when Siri can monitor my heart rate, cholesterol, weight, and automatically schedules exercise as needed.
  • Apple is not good at backward compatibility. I have a perfectly working second generation iPod Touch but a ton of the apps have stopped working.

Silicon Startup

  • At some point in a company’s history it will be either be in one of the following stages: resurrected (IBM), zombie (Yahoo), dead (Kodak).
  • In Silicon Valley, apps that attempt to make Silicon Valley nerds cool or popular get immediate funding.
  • Fund raising is easier the pimping!
  • If the bubbly flows day and night then we must be in a bubble.
  • Pivots are to be the new sport at this Sumner Olympics.

Google IO

  • Facebook has nearly double the amount of users than there are Android devices.
  • Google is demoing Jelly Bean (Android OS 4.1) but still the most common Android version in new phones is around 2.3.
  • The one feature I really want on Android OS is the ability to easily take a screenshot or screencast from my device.
  • Android is still playing catchup to iOS. The audience doesn’t even know when to applaud. #awkward
  • Wow… Jelly Bean has a built it Siri clone. #tailgating
  • “Smarts phones are only as smart as its users.”
  • Android is the perfect stalking device. I knows your appointments, your routes, your schedule, you contacts, your preferences
  • What the towel covered stool in the middle of the stage at? Seems cheap way to reveal the new Nexus 7 tablet.
  • “I read this so many times I don’t know what will be exiting to you”
  • Asus is making the Nexus 7 tablet.
  • The crowd don’t seem as excited as you would think for the big reveal on the Nexus 7 tablet.
  • Still waiting for the killer, must have, innovative features available in Nexus 7 tablet.
  • “Video is stunning in Nexus 7, you can see the individual hair in Ron Swanson’s mustache.” – #awkward
  • Nexus Que?
  • Sergey looks like Larry, Larry Ellison.
  • yeah, woo who – Sergey Brin.
  • The police and military industrial complex are going to love Google’s Project Glass.
  • Google Project Glass available to US-based IO attendees for $1500. Not intended for consumers. Shipping early next year.
  • Android Developer Pack: Galaxy Nexus phone, Nexus 7 tablet, Nexus Q. #oprahmoment

Jul 6 2012

StackOverflow Traffic

There is nothing more that I like than to received a comment to some post I wrote years ago on how it helped someone out. Like this, I’ve come to know that small chunks of code I’ve freely made available are used in production at a variety of sites. It is my hope that the tutorials, examples, and code I write here is of help to others. Even though I like writing tutorials and code to help out my fellow developers, I’ve never answered or posted a question on StackOverflow. My technical blog is really a labor of love and I post around my busy schedule, I’ve never tried to do more than just write about the technology that I use. But even though I don’t use StackOverflow I recently found out from looking at my analytics that I receive a nice amount of visitors from the question and answer site.

StackOverflow Stats

StackOverflow Stats

It always surprises me which posts are the most visited. It’s always the one that you least expect. Either way, I’m always grateful that others have found them useful enough to share on sites like StackOverflow.


Jun 26 2012

Pure JavaScript Charting Library

Most business applications display some amount of data in charts and graphs. If a picture is worth a thousand words, then a clean visual representation of business data is worth a lot more. Business charts can condense a lot of data points into a easy to understand graph.

Recently, I was tasked with updating the graph solution of a financial application with a HTML5 friendly charting tool or library. I looked at about half a dozen JavaScript chart libraries and eventually narrowed the selection down to two based on features and functionality: Google Charts and jQuery chart plugin jqPlot. Both Google Charts and jqPlot support a large number of chart types, from the basic bar and pie to more advance features such as multiple y-axis and and zoom. Both libraries support HTML5 graphics, the legacy chart solution I was to replace generated a pixelated image. Google Charts and jqPlot both draw the graph into div tag instead by using HTML5 graphics and don’t anti-aliasing issues.

For this particular project, we picked jqPlot over Google Charts for the following reasons. Google Charts is not open sourced and it uses a loading mechanism that requires you to be online to load the JavaScript source files from Google’s servers. This is great if you are always online, but the project owners wanted a HTML5 charting solution that works offline. jqPlot is a freely available open source JavaScript library which can be hosted alongside with the other application resources. jqPlot, like Google Charts, has a large number of chart types it supports including line, area, bubble, bar stacked, pyramid, pies, donuts, gauges, and much more.

jqPlot JavaScript Chart Library

jqPlot JavaScript Chart Library


Jun 8 2012

JavaScript StackTrace With The console Object

Error handling and debugging had been made difficult in JavaScript because the lack of tools and the language itself. Unlike Java, that has a strong type and hierarchy of exception classes, JavaScript didn’t even have a direct approach to print the execution stack trace. For years I used a workaround to navigate around stack trace of a method call in JavaScript by using the Function arguments property. In JavaScript, all functions have an arguments property defined. The arguments property is available even if the function is defined with no explicit function parameters. The function arguments property behaves like an array and you can iterate through the argument parameters used to call the function but it also has a reference to the caller via the arguments.callee property. The arguments.callee property references the currently executing function itself, which has a caller property to that of the previous function call in the execution stack.

function basicFunction() {
   var isTrue = arguments.callee == basicFunction; // true
   var callingFunction = arguments.callee.caller; 
}

In the above code, the callingFunction variable holds a reference to the Function object that called the basicFunction.

The caller property returns a Function object or null, so you can chain these until you get to the root of the call stack. You can iterate through a call stack in JavaScript with code similar to the following.

function basicFuction() {
   var caller = arguments.callee.caller;
   while(caller != null) {
      console.log(caller);
      caller = caller.caller;
   }
}

Unfortunately, there is no clean way to get the function name out of the Function object returned by the caller property. This is made slightly more difficult because somethings functions don’t have names if they are created anonymously. If you print or log a Function object, it displays the function definition in its entirety.

Fortunately, the JavaScript console object provides a trace function that will log to the web console the JavaScript stack trace.

function basicFunction() {
   console.trace();
}

If the above function is invoked from an on click event, the whole JavaScript track trace from the on click to the basicFunction function is logged out in the web console. In addition to the function names, the web console in Safari, Chrome, and Firefox have a link to navigate to the exact location your web application where the functions were called.


Jun 7 2012

The Cost of Doing it Wrong

As the saying goes, if a thing is worth doing, it’s worth doing well. It has been proven that doing a thing right the first time is most efficient and cost effective. But what is the cost of doing something wrong? In terms of money, I’ve seen cases where something is done incorrectly and then had to redone at a loss of $100k. In terms of time, you can model it in the following thought experiment.

If a task takes x amount of time to complete and it is done wrong the first time, how long does it take to fix it?  More than 4x. It takes to x amount of time to complete the task the first time, probably at least x amount of time to find out it was done wrong, another x amount to figure out what the first guy did, and finally x amount to fix it correctly.

We all can agree that time is money and if a task is done incorrectly it may cost at a minimum as much as four times as much as it would cost if done correctly the first time around.


May 29 2012

Formatting an Integer to String in Java

There are times when you need to format a integer or double value into a String, with the comma for values larger than a thousand. If you need to format a numeric value correctly based on the local formatting rules for numbers use the NumberFormat class. Different locales have different formatting rules, for example in France they use the comma as a decimal point where in the United States the comma is used for delimiting large numbers.

double val = 123456.78;
System.out.println(val); // 123456.78

// Use default locale to format string
String localFormat = NumberFormat.getNumberInstance().format(val);
System.out.println(localFormat); // 123,456.78
		
String frenchFormat = NumberFormat.getNumberInstance(Locale.FRANCE).format(val);
System.out.println(frenchFormat); // 123 456,78