How to avoid post-construction by using Parts Factories.

I did my first GUI programming on an Atari 1040ST, using Modula-2 and MC68000 assembly language, focusing on such immensely interesting things as implementing general windowing, a resonable blitter interface, raw mouse and non-buffered keyboard access, smooth text cursor and scrolling, and so on, basics that (except for the latter two, or three or four) nowadays e.g. Windows provides, and that in most cases nowadays is down at abstraction levels that you seldom if ever visit. But on the Atari e.g. the quality of printed output depended on the program; each program did it It’s Own Way™. This was around 1986/1987, I was a student and I could not afford a PC, not even a harddisk, much less a Mac (my plan was to convert the Atari to a Mac on-the-cheap, through some half legal means, but I never got that far).

Oh, joys of the PC in the 1990s! Except for lacking coroutines Borland’s Turbo Pascal was much more practical and appealing than Modula-2, and Windows could do so much more – like general windowing, and like printing! I almost replaced Niklaus Wirth with Anders Hejlsberg as my programmer idol (Anders Hejlsberg later defected from Borland to Microsoft, creating the C# language; it’s as if he made a second try at expressing one general idea, the first time with Wirth’s Pascal as his starting point and the second time with Gosling’s Java as his starting point, managing to create much the same “feel” in two languages that at first glance appear to be very different, but which successively filled the same niche).

And, joys of the long-winded rambling introduction! :-) Anyways, with Borland’s OWL framework, as well as with Microsoft’ MFC framework, constructing a window object was a two-step procedure. First, you constructed your “blank” Pascal or C++ object (OWL was available for both languages, MFC only for C++), like building a house without electrical wires and plumbing. And then you called some init method to create a corresponding API-level window, managed by your object, like opening the walls and floors of your new house to stuff in the missing electrical wiring and plumbing. We may laugh today at this totally impractical and error-prone create-unusuble-and-then-fix-it-up Rube Goldberg like idiocy. Or, we could have laughed at it, except that that’s still how it’s most often done!

[… More] Read all of this posting →