Reverse Engineering my own Brain

A few days later…

It is indeed a tribute to the amount of time I spent on flowing and commenting this code, that I have been able to step back up to the project so quickly. Sure there are lots of little nagging snags to overcome but I am following my previous cognitive pattern quite nicely. That is, in everything but one key area.

You see, Netbeans Form Designer does something really dumb. It creates code of the following ilk:

javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(kongzi.Kongzi.class).getContext().getActionMap(ExportDialog.class, this);
exportButton.setAction(actionMap.get("exportSelected")); // NOI18N
exportButton.setName("exportButton"); // NOI18N

oohh… but you already know where this is going. This is stupid beyond all belief. I cannot possibly imagine what imperative posessed the minds of the people who made form designer to do this. This is simply, never a default desire of the programmer. It’s overcomplexity to the extreme.

The problem is that when yguard obfuscates my code, it doesn’t know how to rename the “exportSelected” string.

Now here’s the thing. A year and a half ago, I actually solved this problem. I tripped over the solution one day while reading the netbeans help files. I actually figured how to make it set the event handlers without using reflection. It was literally a one in a million chance. But all I can remember about the incident was that I thought “No one would ever have been able to find this, it’s buried in the help files” and “thank god I figured this out, now I can use form designer AND obfuscate my code!”

Ok so now, nearly two years later, what the heck was I thinking?

I have been all over – and I mean it – all over the help files.

I have looked EVERYWHERE in configuration, navigator and inspector. Nothing relevant. I’ve turned OFF automatic resource management (a good thing I think) but that still didn’t solve the problem.

The best solution I can come up with is to define, say, a jButton by usuing events–>actionPerformed versus “Set Action” which delves into the whole actionMap(x) thing.

The scary thing is, I don’t know if this is the solution I figured out last time, or not. Because I was very happy with the solution last time. I’m worried. I’m going to convert everything to use actionPerformed versus @action, but you know, it’s just scary, because the solution I had last time was so elegant, and now I don’t really remember what I did.

I wish I didn’t lose my backups.

I made lots of backups but they dissapeared.

I feel sick and sad because I lost my backups.

It was only two weeks of work but it, apparently, was the best two weeks of my entire life.

Kongzi Ressurection

You may not know this, but after the last blog post (about Kongzi) back in January 2008, a series of unfortunate events pushed me farther and farther away from developing Kongzi.

I’d like to list them here to help ease my mind. And why, because I’ve decided to focus on finally finishing this promising project.

For one, after I had completely removed all the netbeans auto-gui code, I figured out how to turn off reflection in the gui generator. It all came crashing down. “Shit,” I thought, “I just wasted several days of work”. What was worse is that I would have to redo all the forms because although I had a recent backup I was spending so much time on the project every day that it felt inconceivable to me to go to an old backup. Version Control. Yeah I know, I tried that. It’s a pain in the ass. I don’t want to comment on that. I’ve tried many version control programs for unix, windows, whatever – none of them appealed to me.

Anyways.

I text edited the original files and put back the IDE tags I had removed. So I wasted about a week on that whole adventure. But I finished it and resumed working on the project. Then I did something really dumb, I tried to install a version control system. Version Control systems are great – for large, multiuser projects. For something like this it is a TOTAL waste of time. Backups would have been better. So I lost all my work because the version system wasn’t installed properly, or I typed the wrong flag, or whatever. Poof. You know, I had tried to use version control systems before, really. I am not a novice user by any means. But this was the last straw. I actually had a system up and going which backed everything up for me. But losing all my code.. For fuck sakes – and I do not swear in vain – if I am going to have to back it up anyways I will simply not waste my time with a VCS of any kind.

So you know what I did, I did it all over again.

This is late January now. The program was going exceptionally well. I had all the features I had before. Then I did something which taught me a lesson. I started working on the licensing aspect of the program and I got bogged down. I didn’t really want to work on the licensing and the licensing aspect was boring. Slowly the code started to break in places because it had to be slightly redesigned to work with the licensing code I had written. So I lost interest. This is February now and I posted about how I felt but I didn’t say why I had been losing interest.

A few months later I had a motorcycle accident and I couldn’t type or write for a week or two so that was a problem as well. So by this point I was also into guitar and videogames for a while – well I had always been into games like Hitman, Halflife, Max Payne and so on and that sort of occupied my time. That and work. So I had totally given up on the project.

Now, get this. For some reason I seem to have lost my backups of Kongzi.

I don’t mean all my backups. I mean the “recent” backups from February. I’d just as soon snip out all the licensing code and work on the main project a little more but I can’t. So here I am. What am I gonna do.

First I have to justify why I want to do this. Oddly enough although I am working more than I ever have, I see many ways in which I could use Kongzi at work to help me teach English. Especially now that you can get a mini laptop for under $300. What a deal! Or perhaps it could run on one of those phones with windows mobile or a Palm (if they even make those anymore) and so on. I have a lot of ideas. I always did.

I mean, they sell those little electronic dictionaries. I could use that. But with Kongzi I could tailor it to the needs of an English Teacher. I could sell it as a package – a mini laptop and software. I’d make a lot of money like that. Lol. Or something.

So here’s what I did.

1. I pulled up all my old backups. Dec 17th. Dec 30th. January 3rd.
“Aww crap,” I said to myself. I lost a lot of work. Over a week and a half of amazing stuff.

2. I identified the Dec 30th backup as the day before I gutted the GUI code.

3. I put the Jan 3rd backup and the Dec 30th backup into the latest netbeans (installing, which, was an adventure all it’s own but there really is nothing better.. time has certainly shown who won the recent IDE wars)

4. I started bringing the Dec 30th backup “up to speed” with the Jan 3rd backup, minus all the form removal code. File by file. This will serve many purposes least of all refamiliarizing myself with the code.

When I am done, thank god, I also have those extremely convenient screenshots of what I was doing with Kongzi at the time I gave it up, so it should be trivial to redo the ten or so days of work I lost. And given more than half that time was spent on the irrelevant licensinc code… I am actually pretty excited about this now.

All things considered I could have Kongzi NeoBeta ready to accept new code by early October.

By Halloween I should have more work done on Kongzi than ever. By Halloween I expect to start spending most of my time working on the dictionary. By the end of the year I expect I could be completely finished this with a real live distributable CD.

Hmm. Let’s reintegrate that code and look at the screenshots of Beta-4 first 😦