You are currently browsing the code.timst() posts tagged: Management


Project: Progagil V8

Last year’s summer was by far the longest one for me. 5 months, from April when I finished my associate degree to October when I started my next. So obviously I started a kickass roadtrip across Europe!

Ha, ha, not really. In fact, I pretty much spent the 5 months at my parent’s house. My nice, cosy parent’s house by the coast, but still.  Fortunately, I wasn’t alone in this endless summer: An old friend of mine was here too, and he contacted me with an opportunity for a summer project. It turned out that his mother was heavily into dog sports, and especially “dog agility”, aka gymnastics (or army drills), for dogs: running, jumping through hoops, crawling inside tunnels, you name it.

There are contests of this thing, where people with way too much time on their hands run along their companions as fast as they can while trying to avoid making mistakes. Every dog sport club in France that wishes to organize an agility contest must be registered with the CNEAC, the “National Commission for Cynophile Education and Activity” (whose tag line is “For the betterment of the canine race” — as you’ll see, those guys kind of sounds like cartoon villains). They coordinate the ranking and contest of every single dog club everywhere in the country, so they must have a rock-solid IT system, right? Well, not really. They do, at least, force the canine clubs to use a single software to store the contests results.

Now this would normally be the point where I show you the face of state-of-the-art canine contest management software, except that it won’t work on my computer. Why ? Because my Windows 7 rig doesn’t support 16-bit instruction sets. Oh yeah, did I mention it’s a black and white text program ?

More like nethack

Either Zork, or dog contests. I’m not sure.

Yep, that’s a DOS program shoddily adapted for Windows. Progagil V6, as it is called, come straight from 1994, a year already blessed with the birth of Justin Bieber (no, really, google it).

Although it has been “maintained” over the years (this major version actually come from 2005, and minor bugfixes and addition might have been added no more than 2 years ago), the software is slow, buggy, cumbersome, requires a third-party (and commercial) software to use modern printers (it was designed with dot matrix printers in mind), stores its data in some sort of tricked out CSV files, and has a lengthy manual that contains the sentence “if you do exactly what I say, you shouldn’t encounter any problem” more times than any program should (Hint: it’s zero. The software adapt to the user, not the other way around).

Every time you start a contest you must spend several hours setting it up carefully, lest you ruin the whole endeavor at the tiniest mistake, and at the end you have to print dozens of results sheets with all sort of useless data and send it through slug mail to the CNEAC headquarter in Paris. “Kafkaian” doesn’t begin to describes it.

So the clubs rightfully complained that Progagil V6 was a huge pain in the ass, and in 2007, the CNEAC begrudgingly agreed that it was time to let the ole’ Progagil V6 go. I say “begrudgingly”, because, of course, it was the brainchild of a senior member of the association, who invested a lot of effort into it and didn’t want to see its baby tossed into the bin. But he eventually folded, and the association contacted a software vendor to try to make a new, non-insane software to manage dog contests.

2 years later, for undisclosed reasons (but I would be surprised if the fault was entirely on the developers’ side), the project failed, and now the CNEAC and the company are tied in a lengthy legal battle. Meanwhile, Progagil “15th anniversary edition” V6 was still in service.

In 2010, a new and younger (read : 50 years-old instead of 70) team of amateur programmers appeared in the ranks of the CNEAC and announced that they’ll do a new version themselves, using such cutting edge technology as PHP and SQL databases. The release of this shining piece of software was slated for summer 2010, then early 2011, then mid 2011… And not only was there no indication that the software was actually a thing (rumors stated that the man responsible for the new software had stopped everything in the spring and decided to restart from scratch), but the few reports of field tests of the software were disastrous. It was clear that Progagil “V7”, at is was temporarily called, would not be ready until a long time, if at all. And for the clubs, that meant several more months or years with a software that had seen the birth and death of everyone that was ever entered in its database (good thing it was canine sport).

Waiting for fry : still better than waiting for progagil

Dogs died waiting for this thing.

So there was, in fact, an opportunity right here. The clubs were pressuring the central administration for change. The association had already proved that they were willing to show some cash for a new version of the program. The only problem was convincing them that we were actually able to deliver, which would be arduous, since, you know, the last guys that told them that were a professional company of developers, while we were only two students on summer vacations. To be honest, even I was dubious of my own ability to actually finish the damn thing, since most of my other projects were left suspended forever in a half-finished state (see: the rest of this blog), and that clearly wouldn’t have been enough if the software was supposed to be used by hundreds of clubs in a near-professional setting.

So we instead decided to stay hidden and wait until we had an already completed version of the software. We would then surface, contact the CNEAC, show them our product (probably by demonstrating it to dog club owners first so we could have a “popular support”), and tell them “So you can pay us right here and now and it’s yours, or you can continue your infighting and dabbling in software development for some years while your clubs are getting more and more pissed off”.

Sure, it wasn’t the greatest plan. It was a shitty plan, even, as :

  1. We didn’t secure any exclusivity on the project, meaning that anyone (the software company, the original developers, but most of all the new guy) could release before us and almost certainly beat us, since they already had contacts inside the association, and
  2. It put us at a disadvantage if we ever came to the sale process. If negotiations went awry, they could simply tell us “Ok, no deal. We can wait until our in-house developer finish its own version. But you, what are you gonna do with your ultra-specialized software? Sell it to another dog club federation? Whoops, looks like we’re the only ones. So what now?”. Sure, we might have been able to contact foreign dog clubs, but this wasn’t something that we were quite ready to pursue, at least not until selling our first copy in France.

So, grabbing the V6’s data files, sheets for a future contest in our town and some volunteers’ complaints, we started working on our version of Progagil, the V8.

The program itself is not really interesting. Glorified CRUD with a bunch of views for entering, sorting and displaying parameters about a contest, some neat statistics and other features, but overall, it didn’t exactly change the world. There are some interesting point, though: this was my first time using SQLite, as I always used MySQL or other “heavy” DBMS before. Installing a MySQL server on every dog club’s secretary’s computer was obviously impractical… or so it seemed, but as you’ll see later, not everyone agrees that it’s the IT equivalent of installing a nuclear reactor in the backyard of the house you’re outfitting with heating equipment. But anyway. Working with SQLite was great. I loved the simplicity and the lightness of the database-as-a-file concept.

Another point of interest, which I still don’t know if I should be proud or ashamed of, is the sort-of-ORM I handcrafted for the program. At first I looked for existing solutions, but it was insane. Everything was either awfully complicated or out-of-date, and most of the ORM were engineered toward big, millions-of-LOC enterprise programs running on Oracle databases. After failing to adapt the NHibernate tutorial to SQLite (it was written for SQL Server), I scrapped the whole thing and decided that dammit, I was going to do it myself! And so did I, by using a mix of reflection and standard parametrized SQL statements.

It was remarkably simple to use; you just created your objects with either an existing id (if you wanted to retrieve data) or no id (if you wanted to create a new one), and it will commit everything to the database for you. Every accessor was then completed with the appropriate SELECT / UPDATE queries, so it was pretty transparent: you just used your object like you’ll do normally, and everything was replicated transparently. Naturally, it lacked every single feature that you can imagine, including ACID transactions, complex queries and a bunch of other basic SQL perks, like sorting or grouping (I remember considering using LINQ, but dropped it for some reason). Also, the performance was, well, not that great. As could be expected for a reflection-powered piece of dark arts hacked together by someone who never took a theoretical programming class and couldn’t find out the big-O of his algorithms if his life depended on it. But it worked.

// This method re-fill the object's fields from the DB.
protected void refresh()
{
    FieldInfo[] fields = this.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);

    if (id != -1)
    {
        string txtQuery = "SELECT * FROM " + this.GetType().Name + " WHERE id = " + id;
        DataTable data = sql.runQuery(txtQuery);

        // Tis' be dark magic
        for (int i = 0; i < fields.Length - 1; i++)
        {
            //This get the "Cast" method, and define the type of T
            MethodInfo castMethod = this.GetType().GetMethod("Cast", BindingFlags.NonPublic | BindingFlags.Instance).MakeGenericMethod(fields[i].FieldType);

            //And this invoke it
            object castedObject = castMethod.Invoke(this, new object[] { data.Rows[0][getFieldName(fields[i].Name)] });

            fields[i].SetValue(this, castedObject);
        }
    }
}

I warned you it was dirty.

We toiled the whole summer until it started to look like we could make it fly. So we contacted a local contest organizer and asked them if we could use our system along with the official one, so we could try it out with real data, and maybe talk to the right people in the audience while we were at it.

Well, it turned out to be less of a commercial demonstration and more of a live debugging session, because, as Moltke the Elder famously said, no plan survives contact with the enemy. But it was fun, not to mention incredibly enlightening, to see everything that can go wrong where you’re on live current: bad data, duplicate data, missing data, unintended usages, unexpected usages, and of course, a whole bunch of “wow, this UI really sucks when you’re playing with more than 10 elements”.

After that event however, it was starting to look good. I wouldn’t say that I was proud of it, firstly because this is a goddamn dog contest management application, and also because the UI was ridiculous, with giant buttons and unnecessary progress meters, and the inner workings of the app weren’t exactly rock solid. I was (and still am) frustrated by the MVC model, which I think I never managed to implement correctly. Well I hope that I never did at least, because if that’s it, dear god, what a mess.

But anyway, by that point it was good enough to be at least presented to the CNEAC’s brass. Aaaaand of course, that’s when the news broke that the guys behind progagil V7 decided they had had enough of the vaporware label and actually released something. Or at least they started a beta. Or they will. Anyway, people at the CNEAC believed that this was finally over and were understandably reluctant to pony up some dough for a redundant software made by who-knows-who. And in fact, more than a year later, the “new” software has been deployed at least in some clubs, and the first reviews are, let’s put it gently, less than stellar. Mainly because it requires the installation of a whole WAMP stack on the club’s computer. No, really. Because it’s php, you see. The guy only knew php et MySQL and didn’t want to change his habits by chosing something maybe a bit more appropriate to the task at hand, so he’s now pushing this insanity to every single club in the country.

You know what, I think I better keep maintaining our version so we can sell it in 2027 when they’ll finally have had enough of this one.