The cost of code…

Chris made a pretty map widget thing and threw down the gauntlet

I’m expecting a libjana-gtk/gypsy mash-up from a certain Mr. Burton (no pressure)

Given that Gypsy is my baby, I felt obligated to beat Ross to it 🙂 And so I present

And a massive 87 line program to how how fun and easy it can be to find out your location and then draw it on a map.

#include <gtk/gtk.h>

#include <libjana-gtk/jana-gtk-world-map.h>

#include <gypsy/gypsy-control.h>
#include <gypsy/gypsy-device.h>
#include <gypsy/gypsy-position.h>

GypsyControl *control;
GypsyDevice *device;

static void
destroyed_cb (GtkWidget *window, gpointer data)
{
gypsy_device_stop (device);
g_object_unref (control);

    gtk_main_quit ();
}

static void
position_changed (GypsyPosition *position, GypsyPositionFields fields_set, int timestamp, double latitude, double longitude, double altitude, JanaGtkWorldMap *map)
{
if ((fields_set & GYPSY_POSITION_FIELDS_LATITUDE) &&
(fields_set & GYPSY_POSITION_FIELDS_LONGITUDE)) {
jana_gtk_world_map_add_mark (map, latitude, longitude);
}
}

int
main (int argc, char **argv)
{
GtkWidget *window, *map;
GypsyPosition *position;
GError *error = NULL;
char *path;

    gtk_init (&argc, &argv);

    if (argc < 2) {
g_print ("Usage: %s <device\n", argv[0]);
return 1;
}

    control = gypsy_control_get_default ();
path = gypsy_control_create (control, argv[1], &error);
if (path == NULL) {
g_warning ("Error creating client for %s: %s", argv[1], error->message);
g_error_free (error);
return 1;
}

    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (destroyed_cb), NULL);

    map = jana_gtk_world_map_new ();

    gtk_container_add (GTK_CONTAINER (window), map);
gtk_widget_show_all (window);

    device = gypsy_device_new (path);
position = gypsy_position_new (path);
g_signal_connect (position, "position-changed", G_CALLBACK (position_changed), map);

    gypsy_device_start (device, &error);
if (error != NULL) {
g_warning ("Error starting %s: %s", argv[1], error->message);
g_error_free (error);
return 1;
}

    gtk_main ();
return 0;
}

As you can see, its really not a lot of code. I also added 10 lines to libjana-gtk to draw the marker. Total time taken, about 40minutes, including testing, debugging and discussing a few bugs with Chris. So lets see what sloccount says about it:

Total Physical Source Lines of Code (SLOC) = 80
Development Effort Estimate, Person-Years (Person-Months) = 0.01 (0.17)
Schedule Estimate, Years (Months) = 0.11 (1.27)
Estimated Average Number of Developers (Effort/Schedule) = 0.13
Total Estimated Cost to Develop = $ 1,905

Hmm, we should have scheduled 1.27 months for it and I should have earned 2grand? (not including the code I added to libjana-gtk which would have increased the line count to 90)
Oh, whoops, almost forgot this:

Please credit this data as “generated by pulling numbers out of David A. Wheeler’s ass”

sloccount – for when you need to over estimate EVERYTHING.

A history lesson

A few days ago, I too got an interesting email from a young chap

hi iain,

OMGLOL my name is iain and I am like, sooooo your biggest fan!!! Like, I totali love reading your blog and ur awesome KDE reviews and shit like that!!!1!!LOL that was sooo funni LOL ur awsum!!!! when I grow up (im 29 @ the moment) i want 2b just like u! how xactly did you get 2b sooooooooooo awesum, OMG i  hop u answer soon LOL!!!!!!!!!!!!!!

iain

It is an interesting question and one I think about a lot. How did I come to be so awesome? I’d encourage other bloggers to write about how awesome I am as well, then I can say I started the “how awesome is iain” meme.

But the long answer to iain’s very intelligent and interesting question is this:  I was born and I grew up and there is not a time in between then and now when I wasn’t totally awesome. They say that good leaders are not made, they’re born and that is the same for awesome people such as myself. I am, have always been, and will always be awesome and the sad answer is that no matter how hard you try, you won’t ever be as awesome as me. Maybe you should just buy me something to show your appreciation for all the awesomeness that I bring into this world. I think you should. Unless you’re french and like ManU, we don’t want another “incident
now do we?

Alms for the poor

Well, it’s October and October is that time of year for getting really drunk and inflating the value of your project to scrounge some cash. So I thought I’d join in too.

Obviously the Marlin development costs are astronomical, so please get very drunk and give generously. I spoke with my accountant Jimmy “The Snake” Twoteeth and we’ve worked out that £10grand (thats about $20,000) will cover hosting costs (the live.gnome.org guys are running a racket here), a couple of holid…sorry “developer conferences” in The Seychelles and lets not forget that hookers and crack don’t come cheap…

Obviously I don’t expect you to donate to Marlin without first looking at what we’ve accomplished over the last year or 2. Firstly, most importantly and lastly, we’ve actually made a release. What more can you want?

So give give give today. It’ll cure all headaches and make you attractive to the opposite sex and you can tell potential employers/girlfriends about it.