Grumpy Old Programmer

He’s old, he’s a programmer and he’s grumpy

Archive for the ‘Uncategorized’ Category

Fifty Candles (each)

with one comment

(stackoverflow rep: 4675, Project Euler 72/240 complete)

The first programming language I learned was a peculiar version of BASIC, running on the ICL mainframe installed during my abbreviated university career. I seem to recall it used a magnetic drum as its primary storage device. My second programming language, and the first I was ever paid real money for working with, was COBOL. It was the lingua franca of business computing, had been around forever and I started to learn it early in 1979. It turns out that “ancient” old COBOL had at the time only been around for about 20 years. As indeed had I, and this year we both turn 50.

Ah, the fun we had!

Ah, the fun we had!

When the only tool you have is a hammer, everything looks like a nail. (I remember vividly a school “handyman”, inexplicably nicknamed “Sausage”, who would repair desks by applying a large hammer to drive screws). I used COBOL for things to which it really wasn’t suited. For a couple of years, that didn’t just mean writing peculiar code, it meant punching cards on an IBM 029 punch machine.

Programming for work was done on paper coding sheets, converted into machine-readable format (80-column punched cards) two evenings a week by Hazel the Punch Girl. Times change.

Once upon a time all code was written on these

Once upon a time all code was written on these

It wasn’t as bad as you might think: we only got to compile or run our code twice a day anyway, the rest of the time involved pencils and paper. Lots of paper. Some things change less than others.

Anyway, designing, coding, compiling and testing/debugging a program was a mammoth task: it took months. Lots of months. I think in the three years I was a programmer in my first job I wrote about eight complete programs.

Virgin input to the 029...

Virgin input to the 029...

In all, I was primarily a COBOL programmer for about 12 years, although there were secondary activities in PL/1, Fortran and C in the same period. I haven’t written a line since some time in early 1990. Can’t say that I miss it, not even now that it has object-orientation, a scary concept for a language that didn’t even use to have data scoping below “global”.

So happy birthday to COBOL, whenever it falls during the year. I can’t say I miss you but you paid the bills for over a decade, and for that I’ll always be grateful.

Written by mikewoodhouse

15 April 2009 at 13:41

Lazing On A Sunny Afternoon

with 2 comments

(stackoverflow rep: 2906, Project Euler 59/230 complete)

Below (lightly edited) is a recent answer to a question on StackOverflow. The question is pretty much a waste of time, but what an answer!

Laziness is indeed the first of the Three Programming Virtues, but it is misunderstood. Programming Perl defines it well:

* LAZINESS: The quality that makes you go to great effort to reduce overall energy expenditure.

Good programming calls for laziness, but laziness requires hard work. Good programmers must constantly think of and implement new ways to be lazy. The first compiler had to be written in assembly, and the first assembler had to be written in machine language. Wonderfully lazy, but hard. You don’t get to call it a day after an hour just because what used to take a day takes an hour.

That’s about as close to an encapsulation of my personal programming philosophy as I’ve ever seen. The virtue of Laziness is closely related, if not identical to the DRY (Don’t Repeat Yourself) Principle as espoused by the Pragmatic Programmers in The Pragmatic Programmer.

(I just found myself wondering if there’s a way to refactor that last sentence to remove some of the duplication)

Laziness - all I have to do is this...

Laziness - all I have to do is this...

The idea behind xlUnit (which has been languishing somewhat since being codeplexed in, good grief, September) was to minimise the amount of manual repetition involved in testing Excel/VBA code as it is developed. As a useful side-effect, it also made TDD (Test-Driven Design, or Development, depending on your choice of definition) possible. A fair amount of the code complexity of the framework is involved in eliminating repetitive manual tasks such as test class creation.

There are only three significant UI-level entry points in xlUnit as it stands: application creation (used rarely, only about once per app) class creation, used rather more often, and test execution, which is used all the time. Oh, and there’s a little “Options” dialog, but it only has one setting and that’s not really very interesting so we’ll gloss over that.

Since the first two things are used relatively infrequently, I tucked them away on a menu, whereas the test execution, which is an all-the-time thing, gets a toolbar button. I could have been fancier with that, but I never got past the simple text “Run Tests”, which had the extra benefit of giving a larger target area for the mouse.

...and I get this for free.

...and I get this for free.

There is no interface within the VBE, which is most definitely a shortcoming. To be honest, I only even tried briefly (failing, obviously) to get it to work: with a dual screen setup, which my working environment has had for the best part of a decade, both workbook and VBA are usually visible, so I can get to the “Run” button easily enough. For a similar reason, there is no built-in keyboard shortcut at present. Of course, in Excel 2007, it’s all a bit of a mess. I have the (massive) RibbonX book, by the way, I just need the intestinal fortitude to sit down and read it.

The “Create Testable Application” and “Create Testable Class” routines both live in the add-in itself and are located within UserAccessibleEntryPoints.bas. I’ll come back to “Run Tests” another time – not only was it a bit tricky but I have some new ideas that would make it even trickier.

Choosing to create an application causes a throwaway instance of the xlUnitCodeBuilder class to create a workbook and its tester and create references from the tester to both the application (so it can call classes there) and the framework (so it can use the framework). The same class contains the code to create new classes. I think I put the functions together because they’re about building code but I don’t think I’ve achieved very good separation of concerns here: there’s workbook creation and test class creation and they would probably be better off being separated. Since there’s work to do with Excel 2007 anyway, I think I’ll refactor that bit next time it’s open.

I mentioned “throwaway instance” above without explanation: it’s a way I describe this VB pattern:

    With New UsefulClassThatDoesntReallyNeedToBeDimmed
        .DoSomethingProfound
        .DoSomethingSimilarlyDeep "AndMeaningful"
    End With

Is there a more “standard” way to describe this? Something using “anonymous” perhaps? Anyway, I use it a lot (and I’m now fervently hoping that no-one points out some awful risk that I’m running as a consequence) as it’s a way to get part of the economy of class (“static” methods in Java or C#, where the word means something rather different than in VBA) method.

Written by mikewoodhouse

5 February 2009 at 14:20

Dropping the (logic) bomb

with one comment

My son Johnny (7) was asked a while back (by some feebly unimaginative adult) what he wanted to be when he grows up. “A normal person” was the reply. Fair enough. Not sufficiently deterred by that, the same adult persisted, enquiring what he’d like to do for a job. “What Dad does” was the reply. Good lad.

Actually, Johnny might well be very suitable – he may be borderline Asperger’s, which hasn’t exactly proved a millstone around the neck of a certain Mr William Henry Gates III (OK, no formal diagnosis on that one). More to the point, my little boy has a powerful intuitive grasp of logic already, as the following example should demonstrate.

Assume for a moment that you’re seven years old again, it’s almost time to leave for school and your shoes are nowhere to be found, not an entirely uncommon occurrence in the Grumpy household, if I’m honest. You have utterly no idea whatsoever where they are. Not a clue. They were presumably on your feet some time yesterday, but you can’t really be held responsible for what happened after you took them off, can you?

When presented with a theme park rollercoaster

When presented with a theme park rollercoaster...

Then your mother asks “Don’t you know where your shoes are?”

Pop quiz, Hotshot.

What do you do?

If you answer “Yes”, I’d say you’re showing some real signs of aptitude for programming. Mum, of course is going to be be nonplussed. For all her other sterling and wonderful qualities she’s always going to be the kind of person who centres text in Word through the heavy-handed application of the spacebar.

I’d assert that the answer has to be “yes”. After all, reversing the question to “Do you know where your shoes are?” has to receive the opposite answer. Were we to make the question more explicit, perhaps something like “Is it true that you don’t know where your shoes are?” then the answer is again obvious.

...a small boy has surprisingly little problem finding his shoes.

...a small boy has surprisingly little problem finding his shoes.

I’ve always struggled with these questions myself, having learned that people usually (but not always) expect the “wrong” answer. That brings in the necessity of attempting to work out which answer they’ll interpret as the one I want to give, which makes my head hurt. So I tend to provide the logically correct answer and then qualify it, which gets me an old-fashioned look but ensures that I’m less frequently misunderstood. “Yes, I don’t know where my shoes are”.

Spoken language is trickier, than most of us realise. It’s a reason why taking refuge in the rather less ambiguous world of code is often so comforting.

Note that I am substantially older than seven, have several pairs of shoes and know where most of them are most of the time.

Written by mikewoodhouse

29 November 2008 at 00:48

Posted in Uncategorized

Tagged with

Back And Blue

with one comment

(stackoverflow reputation: 1984)

they understood

OK/Cancel: they understood

While waiting for my eleven o’clock Starbucks this morning (and by the way could someone please tell them it’s not bloody Christmas yet?) I was idly watching two young fellows Macbooking away from the “comfort” of their armchairs. They were hunched over the screen as they did whatever Mac users do and I couldn’t help thinking about how horribly incorrect their postures were from a workstation health-check point of view. I’m a little sensitive to such matters at present, probably due to the prolapsed disc in my lower spine.

At the office I use two 19″ 1280×1024 monitors, each sitting on two packs of paper (on my 4″ elevated desktop) to raise their tops to my eye-level. That gets me to something approximating a “healthy” set-up for my height (6′ 3″, or 190cm). At home, I’m crouching over my laptop like those Mac-boys and despite having almost as much screen real-estate (1600×1050) I can’t concentrate for very long, so I end up leaning back and reading blog posts instead of innovating (you may call it something else).

Mine is like this (only black)

Mine is like this (only dark blue)

I also finally got around to complaining about my office chair, with the result that, after a suitable bureaucratic wait, a rather spiffy new one was delivered, in which I’ve been enjoying correctly-located lumbar support all week, for the first time in years. The difference is, quite frankly, marked.

This matters, because I’m seeking to spend one or two days a week next year working from home, so I think I’m going to need to invest in some serious new desktop hardware. Something with three screens would be nice. A serious new desk needs to be considered, too.

For sitting, I had been planning on a Herman Miller Aero, but I’m now wondering I should be budgeting rather more for one of these instead.

Written by mikewoodhouse

13 November 2008 at 14:04

Posted in Uncategorized

Tagged with , ,

If it’s Thursday…

without comments

(stackoverflow reputation: 1423)

One of my activities on a Thursday is to charge my nifty little MP3 player and load it up with the week’s batch of commute-time podcast listening material.

Beyond Excel, I’m interested in most things within the Agile programming camp, Ruby (on and off Rails), a little bit of .Net here and there and well, computer stuff.

I don’t (won’t) have an iPod or use iTunes, so I have to download stuff as it turns up in Google Reader. Not a huge imposition.

These are what tends to get listened to regularly:

Rails Envy: Weekly, about 15 minutes long and mostly about Rails and Ruby, it’s also funny enough to be worth listening to if you don’t have any interest in the technology. Maybe. “We ain’t got no rspec” (#38) is destined to become a great Ruby catch-phrase. If a programming language can have catch-phrases and in-jokes, that is.

Stackoverflow: Weekly, about an hour, this is usually a rambling conversation between Joel “on Software” Spolsky and Jeff “Coding Horror” Atwood. Up to #25 now (linked) and the most recent included Steve Yegge of Google, who is usually worth attention. I’d say the podcast is starting to find its feet of late as the proponents become more comfortable with the medium.

FLOSS Weekly: Regular hour or so interviews with various open-source luminaries. I don’t listen to them all, but I’ve enjoyed the ones with the original author of Audacity, Simon Phipps of Sun, Ward Cunningham (father of Wikis) and D. RIchard Hipp (SQLite) among others.

Rubyology: You’d think after 71 podcasts, the guy in charge would have sorted out the frequently dodgy audio levels, but apparently not. If you can stand the ropey sound, there’s a reasonably high standard  of Ruby-related content.

Herding Code: Four guys talking about programming topics with some bias towards Microsoft platforms, sometimes with a guest or two. Not the first one I dial up, if I’m honest, but it ticks along nicely in the background.

Not me, I get on at Cannon Street

Not me, I get on at Cannon Street

Fighting Talk: Nothing about computers that I’ve noticed, just a funny sports-oriented panel show from BBC radio, that I tend to miss when broadcast due to the requirement to be ferrying children to various weekend engagements. I hope no-one on the train thinks my occasional inane grin is directed at them.

I don’t listen to anything about Excel – I couldn’t find anything useful. Shouldn’t there be some kind of advanced Excel show? God knows there ought to be an audience for it. Maybe with a banjo theme tune?

Written by mikewoodhouse

16 October 2008 at 14:06

Posted in Uncategorized

Tagged with

Whither (Wither?) VBA?

with 4 comments

Considering the origins of the various Office components (and a light bulb may be flickering dimly in the minds of those who can remember back that far) we’ve come a long way in the application automation stakes. Can you remember Access Basic ? WordBasic? Excel macros pre-VBA? Did earlly versions of Outlook have macros?

Office application macro capabilities have come a long way but they’ve been pretty much stuck at the last version of the VB6 runtime. That’s about a decade with no significant change. In that time Microsoft have hammered their way up to version 3.5 of .NET, but with only half-arsed (my opinion) gestures made towards improving/extending/renewing the internal automation aspects of Office.

I say “half-arsed”, which, I dunno, might be a little harsh, but the whole VSTO thing just seems like a thin wrapper on COM Interop, which is itself a wrapper to permit communication between shiny new .NET code and skanky old legacy stuff. Why do I need to use VSTO at all? If I need complex, compiled high-performance extensions then I’m probably better off getting one of my C++ literate colleagues to write a “proper” XLL add-in that won’t have to deal with COM at all. If I don’t need high-performance then any scripting language that can talk to COM will do the job. Heck, I can use Ruby (and do) – David Mullett has a whole blog on the topic of Windows automation with Ruby.

Microsoft want to get away from VBA, I think that’s clear. They’re never, never, never going to get the current host of non-technical VBA users to switch to VSTO. Forget it, it’s not going to happen. Hell, I don’t want to have to use VSTO and I’m one who should benefit from raising the cost of entry to macro programming. Do MS want to get away from COM? Maybe. They wanted to get away from DDE too, but it’s still lurking somewhere not too deep inside Windows.

How to make an old programmer slightly less grumpy

How to make an old programmer slightly less grumpy

But here we have the Dynamic Language Runtime, which sits on top of the .NET CLR and allows fun things such as IronPython, IronRuby and others. Snappy performance, ability to use .NET libraries, interoperability between languages, sounds like fun. According to Wikipedia, the plan is to move VB to run on it. Now there’s a thought: why shouldn’t Excel be rebuilt in sexy modern managed code, with VBA ported to the DLR and the old COM interfaces reduced to a shim to keep backwards compatibility? Then we’d have macro programming where it should be, in the application, with the billions of lines of legacy code still runnable, and I’d be able to hit Alt-F11 and work in Ruby.

Seems like a win-win scenario to me.

Written by mikewoodhouse

28 September 2008 at 00:01

Posted in Uncategorized

Programming for (programmer) convenience

without comments

Here’s another piece of idiocy from Lotus Notes. I should say that I found this in version 6.5 and in the version that has now been inflicted on me, 8.0.1, it has been fixed. But I won’t let that stop me, it’s still a marvellous example of an entire development team failing to make that one last simple connection:

Could you just for once actually do it, could you?

Could you just for once actually do it, could you?

Have you spotted the idiocy? Notes has recognised that I have the post (sort of) open in the Preview Pane (much as in Outlook) and it doesn’t feel that it can delete it, perhaps because it might leave a decision about what to do with the empty space. So it closes the preview and invites us to try the delete again. Duh.

Just in case anyone’s struggling, I’ll spell it out: the program tells us it will do something we may not have known it could do (automatically close the Preview Pane) and then tells us to manually repeat an action that we know it definitely can do: delete a post. It says “document”, which might offer a clue, but I’m a user here – these are just emails as far as I’m concerned.

In the time it took to code the “problem” identification and the explanatory dialog, the developer could have just deleted the damn post.

Software like this does wonders for my self-esteem, I tell you.

Written by mikewoodhouse

23 September 2008 at 09:10

Posted in design, lotusnotes

Tagged with , ,

CodePlex – hardly any trouble at all, really

without comments

Well, by now there should be something visible here:

http://www.codeplex.com/xlvbadevtools

Which is nice.

Remind me why I decided to put the project on CodePlex again? Oh yes, Microsoft site, programming language, application, not SourceSafe, blah blah, blah.

I did try SourceForge first, I have to admit, but I couldn’t figure out how to hook up my local TortoiseSVN installation to their servers. I guess I failed. CodePlex seemed slightly easier to understand, except that when I tried to import a standard SVN structure it failed, telling me I wasn’t a proper person in Team Foundation Server (or whatever they call Son of Sourcesafe). From scouring the FAQ, discussion forums and whatnot, I determined that this was not a completely unheard-of problem and emailed support.

I had to wait a while, but a response duly came and they’d fixed it. Since it seems to happen a fair bit, you’d imagine they’d try to deal with the problem, but what do I know? The SVNBridge program, which acts as a sort of proxy SVN server so that local SVN software can talk to the CodePlex TFS setup, is now working, although there’s an extra intelligence test needed: you need to append a “_cp” to your username to get a valid TFS login. Strangely, when it wasn’t working, the software was doing that for me, but as soon as the server-side problem was dealt with, I had to type the extra bit myself.

Sneaky. I wonder if these barriers to entry are deliberate or incompetent?

Whatever. It’s there, it’s released and I’ve even logged a couple of obvious issues.

Next, I’ll try to put something together that explains the plumbing.

Written by mikewoodhouse

13 September 2008 at 14:59

Posted in xlunit

Tagged with ,

Mmmmm, Shiny!

with one comment

Browsers++, eh? Google have launched their browser, in beta form at least. Of course, “beta” for Google doesn’t always mean what it means for others – is gmail still in beta, by the way?

Anyway, ever ready to while away half an hour of work time looking at something new, off I went to the download page. A smallish (475KB) bootstrapper pulled down the actual installer, managing to find the necessary information about our somewhat complex Monte-Carlo proxy-server load-balancing  script without grief (presumably by digging into the IE or Firefox connection settings) and ran. Pretty pain-free, apart from this:

Getting warm, getting warmer, oops!

Getting warm, getting warmer, oops!

Ah well, it is a beta, after all. And it appears that the crash may have occurred at the run-after-install bit, since by the time it happened I had a desktop icon that seems – touch wood – to work.

A little detail that I really appreciated was that the install option page included a setting to make Chrome my default browser but it was unchecked by default. Nice one.

And then it just mostly worked. Some minor issues with font sizes, which seemed to randomly apply changes across tabs when I zoomed in or out using Control +?- or Control-mousewheel, but otherwise my regular stuff all seemed to render pretty well, internal or external.

It appears that the Chrome rendering engine shares the same standards book as Firefox’s – both render our IE-specific corporate intranet home page with the same set of “errors”. I tried looking to see what in the CSS was causing the problem but my limited skills weren’t up to the task. But while I was searching the source, which on a right-click/”View Source” request opens in a new browser window, which is nice, I discovered something nice. Nothing earth-shattering, but nice. I hit Control-F, which did what I expected, typed a few characters and the page was scrolled to the first found instance. As expected. Then I noticed something.

Score points for attention to detail

Score points for attention to detail

See what they did? No? Look at the vertical scroll bar. That’s a really nice touch. I like the way the “what to find” box organically grows from the surround too, and the animation is smooth, too. I suppose they could have made it slightly bouncy, in the way that Flash apps seem to like to work these days, although that can make one a little nauseous when over-done.

Oh, and another little plus on the view-source-in-the-browser thing is that links to, for example, stylesheets, are navigable. That removes a tiny piece of Firefox excise that I didn’t previously even know existed.

I’m sure there are all sorts of other little things. The address-bar within each tab may prove to be a boon, and the process-per-tab thing could be useful, although I can’t say crashing ranks very highly on my list of browser annoyances. We’ll have to keep sucking it to see.

I won’t be deleting Chrome. Neither will it be elevated to the status of default browser in the short term – I’m far too fond of my little set of FF add-ins. When Chrome has features that give me the capability provided by, at least, AdBlock, Firebug and Greasemonkey then we may be in business. But I think it’s going to be something of an uphill struggle until something really compelling and unique is offered. The thing is, Windows users who cared have already switched from IE to (mostly) Firefox and I don’t see a reason, other than possibly the bleeding-else coolness, to change again.

At least, I don’t see the compelling reason to switch yet.

Written by mikewoodhouse

3 September 2008 at 14:22

Posted in design

Tagged with , , ,