Friday, August 10, 2012

Paradigm Envy

I read a lot in the past few years about Continuous Deployment, and I finally realized what about it seemed odd - I've spent most of my career working on systems that were not web-based, but installed individually at customer sites.  So all those wonderful ideas about rolling out new code on the fly just don't apply to me.

And I really envy those developers who can use it - you avoid all the hassles - customers who never upgrade; customers who want fixes in the new releases backported to their current release; customers who want you to fix the problem, but not change any code, since they have to test for 6 months before deploying code.

Maybe someday I'll get the chance to work on a system that CD will be applicable


Thursday, August 09, 2012

Naming Names

In What's In A Name? I addressed a common problem - the naming of functions.  I suggested that predicate functions be named so that reading the code aloud is comprehensible.

Today, I realized that there is a corollary that applies to a common type of function, the setter.

Often you have a setter function that has a small set of values, typically a binary flag.  There are two common schemes for getting/setting the flag - set(flag,. value) + getFlag(), and setFlag() , clearFlag().

From a code comprehension standpoint, the latter is better.  You can read the code and no matter what the value is, know if the flag is set or clear.  No more having to search back in the code when you see:
setFlag(someVar);
to see if someVar is True or False.  You know immediately at that point how the flag is set.

Now, you will probably need a getter still, since you will likely need to printout the value, at least, but the cognitive easing of this will be good for you, your successors, and your code.



Tuesday, July 03, 2012

Bullpen Bullsh*t

I really need to get promoted high enough to get a hard-wall office.

The past few weeks has been one pet peeve after another.

If I had an office with a door, I could at least shut the door and eliminate the worst of the annoyances.

Firstly, a few of my cow-orkers have voices that carry across the cube farm.  I really should get an acoustical analysis to see if it could be weaponized.  So throughout the day I get to listen to their insurance issues, missed appointments with cable installers, and complaints about other people in the group.

Second is the wonderful world of not using tools we already have.  About once a week there is a morning conference call that involves about 10 of the nearby people, along with a number of offsite people.  So everyone in the office decides to work through the call, and the Powers-That-Be do not release headsets without paperwork, so everyone on the call is using their speakerphone.  As a result, I get the call in 5.1 surround sound, including the echo-delay from the further people being audible directly and via the closer phones.

Third was another case of Musical Chairs Responsibility.  There was a customer issue that had been partially described by the Project Manager, and we had no reason to believe that the short description was at all accurate.  So when the PM sent another email asking if Engineering had any solutions, I repeated the original case that we had no reason to believe that our area of the system was at fault.  Shortly after, my boss's boss assigns the problem to me, since I foolishly spoke up.  And what do I find after testing the system?  The problem is not in my area, but in the data input area.  So if the developers for that area had actually looked at their code, they would have found it.




Wednesday, May 09, 2012

There's Never Time To Do It Right....

I got bit today by a bit of false economy.

We had a message to a piece of hardware that needed a flag sent, but there was no time to alter the existing protocol to add an explicit flag.  So someone, years ago, resorted to a little bit-twiddling in an existing field.  However, instead of setting that bit in the field right at the places where it was correct to set, they put the check and set in a function called later.

Fast-forward to now, when I move some code to fix another issue, and this bit setting is now hidden away from the field population, so I have a value that is mangled after I use it, and the bit is not set correctly.

The only reason I can think of for why the original developer did not just put the check and set in the places it was needed is that doing so would alter more files, and someone decided it was better to make a change in one file.  In other words, a false economy, one that would have been better to have changes the multiple files and put the change near its use instead of in another function almost wholly unrelated.

So think well before you allow someone to tell you that its better to compromise proper separation of concerns.


Saturday, April 14, 2012

Do Have A Cow, Man!

It looks like I've got another "old fart" programmer rant here.  Josh On Design has an open letter to language designers in which he urges them to kill a few of what he feels are sacred cows of programming language design.

Some of his points are ones that I can't disagree with (type systems, garbage collection, extending the syntax), but his points 1, 2 and 4 stick in my craw

Cow #1 is "stop storing source code as ASCII files on disk".
Cow #2 is "use an IDE that is more than a text editor"
Cow #4 is "stop using whitespace or indention or braces styles"

For #1 he suggests storing code in XML/JSON or a database, and storing the code structure, along with any metadata, and non-text resources together.  This is not a bad idea, but it seems to gloss over one detail - a programmer will need to read the code to understand it, so it will end up being displayed as text in the end, even assuming it's not XML.  His point is that once the structure of the code is set, having a compiler/interpreter extract that structure every time is wasteful.  It is, but it gives the programmer great flexibility.  The only thing like what he suggests that I can imagine is something like the visual programming languages that represent the constructs as icons with slots for the details, like a loop is an arrowed circle with the start, end, and increment values inside the circle.  But what if you need to change from a loop to a recursive call?  You would need to somehow remove the loop icon and replace it with another icon (drag&drop?  emacs-like ctrl-meta-bucky keys?) and fill in the recursion endpoint and recursive calls.  And you'd have to find a set of symbols that would be clear to all programmers, which is not an easy task.  The great benefit of written languages is that they can carry a lot of meaning in a compact form.

For #2, he promotes requiring an IDE, since the source code would not be in a pure text format.  IDEs are great tools - I was reminded of this recent;y in a class where Eclipse was being used, and the auto-import feature for Java code was really useful.  But if the code requires an IDE to even look at it, you are adding complications - the language structure is now tied to the IDE understanding it, or you get incorrect rendering.  Then you must wait for the IDE developers to update their code before you can safely work on your code.  This seems a bad idea, especially if the IDEs are commercial tools, where corporate interests will have undue influence on the process.  I was distressed to hear, years ago, that a C++ feature was misimplemented in the official version because one of the corporate members of the standards committee did not want to be forced to fix their broken extension of C++, and ramrodded their version into the language.  Now imagine something similar, but where a good feature is rejected because a corporate member doesn't want to update their toolset!

Point #4 is superficially on target.  Arguments over brace style and how many spaces a tab should be are probably the least useful, and most heated, disagreements in software.  However, they are underlaid with a critical point - we need to understand the code to work on it, and different people find different layouts more suited to their mental models.  But the point is a bit of a strawman - there are already tools to adjust the layout to suit - store the code in one format, and have the repository filter it to your favorite style on checkout so you see it in the style you prefer.

Basically, the point of source code is to provide the programmer with an easy-to-understand format.  We have lots of computing power now, so why not use that to deduce the details, instead of making the human do the drudgework - compilation/interpretation can be done from the text much faster then understanding the code intent from a complex layout.

Now, it is still a good idea to perhaps save an intermediate step in a non-human-readable form, like Java class files or Python .pyc files, and there is always room for better ways to organize the source code of a project and its libraries, but assuming that one-size-fits-all is almost certainly going to fail.




Friday, April 13, 2012

The Circle Of Life

One of the funnier things about this profession is how so many things are cyclical.  Language mavens are fond of saying that every programming language eventually turns into a poor copy of Lisp, and every 10 years or so there is another format for encoding data so that the machines will have some ideas of how to process it (ASN.1 was XML before XML was born)

So I was tickled to read about Taco Bell Programming, where Ted Dziuba describes how to do web crawling and MapReduce with UNIX utilities.  It rang true, especially given the current situation at The Job, where new tech is being enthroned.  Then I found Mike The Coder's post about his reaction and Ted's response, which was even better.  I find new things about the OS every time I look, and there are great ways to do most tasks already in place.  But every generation needs to invent its own set of tools before it learns that much of what they want is already there,

It's almost like the end of The Wizard of Oz, where Glinda tells Dorothy that she would not have believed that the ruby slippers would take her home before she experienced the magic in Oz.

Heck, given the number of flying monkey's I've worked with, that's more apt that I care to think about.....

Thursday, April 12, 2012

Why We Code (again)

(As opposed to Why We Fight)

I've always felt that there was a unique property of writing code that was not found in other professions - getting in the Zone, seeing the data in your mind, making a machine do your bidding.  It's something that I always like when I get the chance to write new code (a rare occurrence these days).  Debugging provides the thrill of the hunt, as an alternative to pure creation, for variety.

So I was greatly pleased to find someone else who considers himself Lucky to be a Programmer

Gustavo covers much of the same ideas that I have felt, and I'm heartened that an apparently younger programmer (or at least newer programmer) is still finding the same joys in the work.