Thursday, December 27, 2007

Web Graphing

A few weeks ago Google released a graphing api. I thought I'd take a look at it since I am working on a personal project that requires statistical displays.

First, I want to say that the documentation of the api is really good. Every time I was not sure how to do something I could easily find out the answer in the documentation. Second, the graphs produced look nice. Three, pie charts were very easy to create.

That said, I found it very difficult to do anything else. While trying to render a nice line graph I ran across a few problems. Well, not problems but challenges. The first one is that the api really isn't "smart". What I mean "smart" is if you have 5 data points, but 6 points on the axis, the api doesn't adjust the points to line up with the ticks. Also, the x,y axis scale from 0 to 100 so if you are charting negatives or numbers outside that scale, your application needs to do an algorithm that figures out what data point resolves to the actual data value. Another problem is the the axis do not scale themselves to the data. This requires yet another algorithm to determine the labeling of the axis. Oh, and be sure you do the scaling before you do the charting or else everything is a mess.

So, after working with the api I started to wonder if there was anything better. After going through all the tools that cost way to much, I found a handful of charting tools that were free. So I thought I would go through them until I found one I liked. I got lucky and the first one I tried was super easy to use. The tool was very configurable, yet able to do to basic things like scaling on its own, of course this could be overridden if needed. The labeling of the graph was better as well. The tool I found was called ZedGraph.

For example I create the same line graph with both apis. Using Google's api took me about 5 hours to get it right and maybe another hour or so making the graph pretty. Using Zedgraph I did the same graph in about an hour. That includes making it pretty.

All in all I am a little disappointed in the Google offering. I think maybe my expectations were high because all the other Google tools I use(see past blog posts here ) work very well, and are easy to integrate.

This brings me to another pondering, is Google doomed to fail because of there past success? People will expect nothing but the best from Google and if future Google products are good, but not great, will people will sour on them? I will save that discussion for another day.

Friday, December 21, 2007

What I learned on my recent trip to Los Angeles

Here is a list of things I learned on my trip to and from Los Angeles.

  1. It is not always warm. I left the cold snowy state of Wisconsin expecting to get to L.A. and having sun and warm weather. Instead I found rain and mid to high 50s.
  2. I have been in many cities where I thought traffic was bad (New York, Toronto, Washington D.C., Las Vegas) None of those cities can touch L.A. We are talking 8 lanes of bumper to bumper at 10:00 am in the morning. Add to that the motorcycles that ride between cars in adjoining lanes and you have a recipe for disaster and mayhem.
  3. I can leave my Sirius radio on in my car for three straight days and it wont completely drain my car battery.
  4. I can sleep through anything. While in L.A. there was an earthquake that registered 4.0. I slept through it though.
  5. Everyone in L.A. seems to be in some way connected to the film industry. Everyone I spoke with has either been in a movie or connected to a movie in some way.
  6. The Denver airport is not all that great. It is just a long building that is not fun.
  7. TAS at LAX is perhaps the worst. It took us an hour and forty-five minutes to get through security. They had one xray line running during the middle of the day.
Well that is all.

Thursday, December 06, 2007

Code Duplication Woes

Code duplication is EVIL! We all know this right?

First let's define duplicate code. I will take the definition right off of wiki....

Duplicate code
is a computer programming term for a sequence of source code that occurs more than once, either within a program or across different programs owned or maintained by the same entity. Duplicate code is generally considered undesirable for a number of reasons. A minimum requirement is usually applied to the quantity of code that must appear in a sequence for it to be considered duplicate rather than coincidentally similar. Sequences of duplicate code are sometimes known as clones.

The following are some of the ways in which two code sequences can be duplicates of each other:

  • character for character identical
  • character for character identical with white space characters and comments being ignored
  • token for token identical
  • functionally identical
So why is it bad? Well for many reasons, one it causes the cost of maintenance to go way up because now not only do you need to change the code once, but you need to search the code for other ares to change. Make the code fatter. More code is not easier to understand. More code also takes longer to write.

Let me give you an example I just came across in the last few weeks. I have been doing some work patching a website. There was an error that was occurring anytime two new products were added to the database and a customer was purchasing one of the new products. Do I had to debug the issue. Basically what happened was the developer who wrote the web page that was failing decided he was going to create two static arrays. One array would hold all the prices of products, and the other would hold the product descriptions. he then put he item in the array at the array index corresponding to the database product key. that way when the page was passed the product id, he could look in these arrays to get the info out. Well, what happens if you forget to update these arrays when adding new products, well you get index exceptions and pages crashing. I have know idea why the developer did this. I mean you have the product id why not just get the details from the database? This poor design and duplication cost real world dollars.

Please never duplicate code, data or logic in a software application. It is never good practice. Oh there are tools you can get to search for code duplication. The one tool that comes to mind is Simian. I have never used it, but I might start.