The Humble Programmer

I ran across a reference to E. W. Dijkstra’s 1972 essay “The Humble Programmer” recently. I’d never read it before, but I like to think I already understood the concept. Any sort of serious programming job is going to reinforce a programmer’s humility on a fairly regular basis, unless the programmer in question is incredibly good, or incredibly deluded.

The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.

At my current job, for the ERP system I work on, we do production deployments once a week, usually. We may do a post-deployment fix or supplemental deployment occasionally, but usually only if a really show-stopping bug made it in. (The deployment process is apparently time-consuming and arcane. I don’t really know how it’s done, exactly, but I think it involves ritual animal sacrifice and long incantations from the Necronomicon.)

I managed to introduce two exciting bugs into the system in last week’s deployment. So this week’s deployments include:

  1. A fix to a problem that I knew would occur, under a certain set of circumstances, but which I thought would probably only occur once in a blue moon, if ever. Instead, it happens about 20 times a day. One user referred to it as “really really really frustrating” and “a horrible inconvenience” in a support ticket she opened.

  2. A fix to a problem that had never even once occurred in testing, and which I have still never been able to recreate in testing. In production, of course, it happens about 10 times a day. And since I still haven’t been able to recreate the issue in the test environment, I can’t really be sure if the “fix” actually fixes the problem.

So, basically, my errors have been annoying the heck out of our users for the last week, and I have once again been reminded that I am fallible, sometimes spectacularly so!

Code Complete

Code CompleteCode Complete by Steve McConnell
My rating: 5 of 5 stars

I started reading Code Complete years ago. (More than ten years ago, I think.) It’s a great book, but I kept putting it down in favor of more specific programming books, usually ones that I needed to read for something I had to learn for work; a new language or software package or whatever. And then I kind of forgot about it for awhile. But I finally got back to it in 2014, and just finished it up today. Near the end, I switched over from reading my hard copy of the first edition to reading the second edition on Safari.

Although the second edition is fairly old now too, and some of the specifics in it could be considered out of date, I’d say that almost everything in the book is still applicable.

The book, overall, is a solid introduction to the “best practices” for a professional software developer. It covers a lot of stuff that’s applicable for any professional programmer, regardless of the language you’re using or the environment you work in. McConnell has a lot of specific advice, and he backs it up with data; this isn’t one of those books that reads like a religious screed. It’s not just opinion.

If you’re making your living as a computer programmer, you should really read this book.

View all my reviews

Dynamics AX silliness

How’s this for a post title?

Compare Tool causing a failure, forcing an element restore which results in negating the changes made on the element

Yes, in Dynamics AX, the ERP system I work in every day, using the “compare” tool can destroy your code! Admittedly, it’s an edge case, and it’s not likely to happen terribly often. But still. Compare tools should not actually mess up your code! (Merge tools should, maybe, sometimes. But AX doesn’t even have a merge tool. Don’t get me started…)

Farewell, Dr. Dobb’s

Sad to see that Dr. Dobb’s is getting shut down. I had a subscription to the old print magazine for many years. They had some great, useful, well-written articles and columns, from people like Michael Swaine, Jeff Duntemann, and Al Stevens.

There are a lot of great programming resources out there on the internet, of course, from Q&A sites like Stack Overflow to podcasts like .NET Rocks. But I don’t think there’s anything else out there that’s quite like Dr. Dobb’s was, in its heyday.

Dynamics AX documentation annoyances

So there’s an event I can override, with the following signature:

public void cursorNotify(int _event)

So if I look that up in the documentation, I should be able to see what values I might get for the _event parameter, right? Nope.

It says there’s going to be a table of event IDs, but there is no table.
Go back to the AX 2009 documentation, though, and you can see the table.

And hey, it even has some example code. A lot of the AX 2012 documentation leaves me with the impression that it was automatically generated, and then never reviewed by an actual human. And that they don’t really want to bother updating it or improving it And, sometimes, I feel like I need to vent about that…

So Much Microsoft News

Wow, so much nifty news coming out of Microsoft this week! Scott Hanselman has a good overview. And The Morning Brew for today has a great round-up of links to various blog posts from within Microsoft and elsewhere.

I’m definitely excited about the new Visual Studio Community version. I’ve been using VS Express at home, for my various recreational programming projects, and it’s not bad, but I’m glad that I can now use a version of VS that supports extensions, and doesn’t impose artificial barriers between desktop and web development.

Oh, and F# 4.0 looks interesting!

Using RecordSortedList in Dynamics AX 2012

Dynamics AX 2012 has a nice class called RecordSortedList, which can be used to create a list of records from a database table. It can be useful when you need to pass a list of records into a method, or return a list of records from a method.

I honestly haven’t used it that often, but I had a case today where I thought it would be perfect. I had a method that currently returns a single record from a table, but that needed to be changed to return a short list of records.

I wrote some code to insert records into the list, then another bit to loop through the list and do something with the records in it. I was puzzled that, while I was definitely inserting multiple records into the list, I was only getting a single record back out. After some trial and error, I discovered that the methods to retrieve records from the list don’t really work right if you fail to explicitly set a sort order on the list. I wasn’t really concerned with sort order, so I didn’t bother setting one at first. Once I set a sort order, everything worked fine.

If you want to see this quirk for yourself, run the test job below with and without the sortOrder() call. As far as I can tell, this isn’t actually documented anywhere, so I thought I’d write up this blog post, as a reminder for myself, and as a resource for anyone else who happens to stumble across this little quirk.

// https://gist.github.com/andyhuey/84495f8a3480d2df31f9
static void AjhTestRSL(Args _args)
{
    CustTable custTable;
    RecordSortedList myList = new RecordSortedList(tableNum(CustTable));
    boolean moreRecs;

    myList.sortOrder(fieldNum(CustTable, AccountNum));

    // create a list
    while select firstOnly10 * from custTable
    {
        myList.ins(custTable);
    }

    // step through the list
    moreRecs = myList.first(custTable);
    while (moreRecs)
    {
        info(custTable.AccountNum);
        moreRecs = myList.next(custTable);
    }
}

WordCamp NYC

I’m Attending WordCamp NYC – August 2-3, 2014
I’m planning on going to WordCamp NYC this weekend, barring any unforeseen circumstances. I’m looking forward to it, since I haven’t been to anything like this since Drupal Camp in 2012. The schedule looks pretty interesting; I should be able to learn some stuff.

WordCamp won’t really make up for missing San Diego this year, but hey, it should be fun!