Guy Who Reopened The Singleton Can Of Worms

I am the person that picked at the open sore that is the SingletonPattern.

I came to this site looking for some edifying discussion on design. I'm working on a rewrite of a program that works fine but is a bit 'crufty', since object-oriented extensions were added to a procedural/event-driven system. I would not dignify what I am doing by calling it 're-factoring'. I am rewriting and borrowing code from myself as I go along.

I encountered what seemed to me to be a completely wacky debate over matters I thought long settled. In fact, I think those matters were essentially settled before the GOF book was even written. I was a little blunt about my 'opinion', but really - [I am hoping I will remember to include the references here when I put them into place]. The debate is about the SingletonPattern. I think the pattern is basically a 'brain-fart' by an otherwise admirable group (GOF).

Rationale: It is a dumb discussion that makes this community look foolish. As canonically expressed in the GOF book, the pattern is simply to be avoided. I can find no place on this wiki that presents even a weakly convincing argument for either of the properties of this pattern. I think that would rather be a pre-condition for the superfluous joining of these two properties to make sense.

One of the Singleton aficionados seemed to think that it was important that he understand the provenance of the arguments rather than the arguments themselves. So be it. My protestations that it is entirely irrelevant with respect to the debate at hand did not work. I am basically 'refactoring' my entry into the wiki to satisfy his capricious demand.

I am a working programmer. I first learned programming in 1976, but I really did not gain 'traction' until about 1978 or 1979 (who remembers that far back) when I had (and used/abused) unfettered night-time access to a mini-computer running some ancient operating system from 8 inch floppies. It essentially had a 'monitor program' that was a variant of BASIC. I was taught BASIC by the owner (a fine man who is greatly missed). I shortly thereafter bought my own Atari computer and entered 'the zone' for good. I started programming for a living in the early 1980s just around the time the IBM PC became popular. My first 'hard-core' work was in BASIC and assembly on the (then) fabulous Apple computer. At the time, it was heaven. I could not stop smiling. The monitor program on the Apple, BTW, was a bit of a come-uppance. It was (memory is fuzzy) either a straight (ish) machine language environment like the old 'OS Debug' or something very like it. Dropping to the monitor was not something I liked to do.

I have worked on many systems from tiny hand-held devices with 128 bytes (sic) of memory on up to multi-billion dollar enterprise systems with Terabytes of storage. I have written code in many different languages over the years. Most recently, I have been coding C/C++, VB, PHP and SQL for a small (sounds big but it isn't) system. It is this latest project that led me to this wiki.

My roots are deep, but I have coded nearly on a daily basis for most of my life and I stay reasonably current. I am concerned with real-world production systems that actually go into and stay in production at a cost that is bearable. I therefore don't spend too much time with 'flavor of the month' stuff. I do take a peek from time to time at things like Ruby, Eiffel, Haskell, the .NET architecture, what's current in Java-Land, etc. I came from (long ago) variants of assembly language (a lot of 6502 by hand-assembly), Specialty languages for science courses whose names I have forgotten, many, many dialects of BASIC, FORTRAN, PL/1. I dealt with (though never in production) COBOL and RPG. I had a nice several year fling with Turbo-Pascal 3 that I remember fondly and Modula-2 (the only compiler I ever bought with my own money). I began coding in C in 1984 and hated it. By 1985 I loved it.

People slam the C programming language as being like high-level assembly language. It is to laugh. I find that funny on many levels. It is like calling evolution 'tautological'. The absolute power and speed of assembler combined with the power of a beautifully constructed, elegantly small, extensible, (now) standardized language with top-notch compilers, support everywhere. You get the picture. I still like the C language. When it is the right tool, I use it with relish and without apology.

Anyway, I was once a bit of a programming language 'junkie'. I have dabbled in pretty much everything, including things like Lisp, Smalltalk (I am still keeping my eye on squeak), Haskell. Rebol comes to mind for some reason. I really, really wanted that to pan out. I still really do not like Perl, but it does a job and I do use it from time to time. I spent a couple of months writing arcane Sybase database management code in Perl. The result was pretty amazing, but I still do not like the 'look' of Perl. I have 'coded' in strange things like Dbase/Clipper for money. Actually, my first time round with Perl was only because I was paid to do it.

I'm 'old school', so I still do lots of stuff by hand. I resort to debuggers only in extremis (quite rare these days). I use what I think of as 'scaffolding tools' for design - example: DBDesigner 4. What the heck. It's a nice tool, saves time and generates code that is still code. Like a bit of a 'flaky artist', I use lots of tools to sculpt software - vector drawing programs, image editors, spreadsheet software, Word processing software, presentation software, PDF creation stuff, etc, etc. I am skilled enough with the various tools to construct a complete working system end-to-end including installation software and help files. However, I can't say I love it all. Some of it is drudgery. I took formal classes in typing in the 1960s, so I actually enjoy the typing part of it. In my early days, programmers often typed with two fingers at excruciating paces. I would sometimes kick them out of the chair just so I could type and we could get on with it.

I spent some time with a defunct startup doing library code for a Java framework and used the various design and development tools appropriate to the task. It was not much fun. Swing was not even available at the time. It was tough slogging to produce real stuff.

I manage a bunch of stuff on the Internet, so I have to 'deal' using the various tools. I get by. I was once a Unix admin and once a DB admin. I have taken formal lessons in both. That was development support and it paid the bills, but I'm not a career admin guy. Despite that, I am a 'hands on' kind of guy. I write my own PHP and style sheets (and even very limited snippets of JavaScript) for my various servers. I also admin the MySQL databases, Apache, etc. My own local network runs on W2K, but uses Apache, MySQL, PHP and Cygwin for anything I can get away with. I run a whole bunch of virtual servers on the local network to mirror various live Internet domains. I hack the various configuration files for Apache, PHP, etc by hand. So far, so good.

I was once very much 'bleeding edge'. I settled down to 'leading edge'. I am not really 'trailing edge' now, but I am approaching it. I have worked with .NET, but I am holding back. I have done lots of work with Java, but I am still waiting for the blessed thing to stabilize. Don't get up on your hind-legs Java weenies. I am just reporting the news. Java is astonishingly fast for the type of language it is. In some of my benchmarks with our compression code, it was about 1/2 the speed of the equivalent C language code. That is quite amazing. The Java community is quite literate and for the most part I at least comprehend why they keep shifting the sand, even if I don't agree with it. Remember that I am a developer of real production code. When we had to go from J1.2 to J1.3, our code broke. They simply deprecated some of the classes we used and replaced them with things with zero backward compatibility. We had to re-design and re-code a bunch of stuff from scratch. That is a no-no when it takes the bread off your table.

Speaking of the above, personally, I am married with children. I suppose I could starve myself for my craft, but I can hardly ask my family to do so.

For a laugh, I am going to include a tiny x86 assembly program below so that people can get an idea of why I presume to weigh in so strongly on some issues. I wrote the code and having seen much assembly code from that era, I can tell you the code is quite nice. Note that more than two decades have passed during which time I allege that I have programmed almost daily. I have likely spent more than 30,000 to 40,000 hours programming or learning about it since I was at the skill level demonstrated below. Compare that to hours at University (http://web.mit.edu/catalogue/overv.chap5.shtml - less than 800 hrs per year). You can see that I have likely covered a lot of ground even if (as intimated elsewhere) I am a slow learner. This is not a slam by the self-taught against formal education. I have the credentials too.

I would like to show some recent stuff, but unfortunately it is either confidential (or even owned by) various other entities or it is published on the net (or about to be) and would reveal who I am. It is my preference not to do that. One bit of code (ANSI-C - to implement a certain RFC) that I published under the GPL a few years ago has made it into Linux. I would sort of like to show that, since it's 'cute'. Unfortunately, it has my name plastered all over it (and the code is all over the Internet).

Again, it would be a bit too revealing to speak about my various employers. However, I have worked for many well-known software firms (see below). I am also an active (not as much as I should be) participant in various online endeavors. Sadly, specifics for that also make me too easy to find. Ironically, I am the designer of more than one scheme to ensure anonymity.

I mentioned elsewhere that it would be easy enough to find me, if you were clever and persistent and/or unethical. I expect that most people in a position to do so would be intelligent enough to realize why that's not such a good idea. I mention this, because of a similar discussion years ago where someone did a 'whois' against my domain name and fancied they were geniuses for 'outing' me. Sigh.

I started to list the names of well-known companies I have worked with, but found that I came up as the first entry on Google with too many combinations of less than six words. WTF? There are more than a hundred times as many references to 'Ward C' than there are to me on Google. For some reason, Google seems to over-rank me against technical keywords. Does tenure in cyberspace affect ranking or something? I'm even easier to find than I thought. I swear that I am neither that well known nor that influential (just look at how little impact I've had on this wiki). It's a bit creepy. Mind you, I suppose there are not many actual hands-on working programmers that have been at it for so long. I try to keep a low profile, but I am obliged to maintain a presence on the Internet as myself.

I actually had a more sophisticated method of finding me in mind when I said it would not be that hard. Do not Google for me. I will not count that as a fair 'find' and will deny it with vigor.

Anyway, I assert that this entry more than satisfies any reasonable notion of establishing at least the nature of who I am. I can't imagine a non-programmer making such an entry.

                               TITLE BRKHNDLE.

;**************************************************************************** ; ; BRKHNDLE.ASM ; [Name withheld] 04/18/85, 10/27/87 ; ; These are the interrupt handler routines for the break interrupts ; 0x1b and 0x23. ; ; This module provides the global variables: ; ; _userbreak -- flag indicating that break has been pressed. ; _breakset -- flag indicating that handler is installed. ; _oldvec6c -- storage for original 0x1bh interrupt vector. ; _oldvec8c -- storage for original 0x23h interrupt vector. ; ; ; The handler ( brkhndle() ) is installed and removed by the functions: ; ; disablebreak() ; enablebreak() ; ; This was written for the installation and update routines for the ; [A medical] Management system. ; It is intended for linkage with the Microsoft Version 4.00 C compiler, ; under the large memory model. ; ; NB: Routine changed to COMPACT model for use in a backup/restore ; system. [Name withheld] Oct 27th 1987 ; ;**************************************************************************** ;(*.PA*)

_TEXT SEGMENT BYTE PUBLIC 'CODE' ASSUME CS:_TEXT

;**************************************************************************** ;* * ;* Break handler * ;* * ;****************************************************************************

Public _BRKHNDLE,_userbreak _BRKHNDLE proc near

starthandler: ; MOV CS:BRKREQUEST,1 ; SET BREAK FLAG (_userbreak). ; ; The handler for 1b has to ; be super short. I believe ; this fits the bill. IRET _BRKHNDLE endp

;**************************************************************************** ;(*.PA*) ;**************************************************************************** ;* * ;* Disable break (Install Break handler) * ;* * ;****************************************************************************

Public _disablebreak _disablebreak proc near push bp ;***** ***** mov bp,sp sub sp,4 ; Standard entry code for c library functions. push di push si ;***** ***** startdisable: MOV AX,CS:BRKVINST ; CHECK TO SEE IF INSTALLED CMP AX,0 ; FLAG NOT SET. JNE installed ; SKIP INSTALLATION IF SET.

PUSH DS MOV AX,0351BH ; GET INT 21H ; AND MOV CS:OLDINT1B,BX ; SAVE MOV CS:OLDINT1B+2,ES ; OLD INT 1BH VECTOR

MOV AX,03523H ; GET INT 21H ; AND MOV CS:OLDINT23,BX ; SAVE MOV CS:OLDINT23+2,ES ; OLD INT 23H VECTOR

PUSH CS ; SET POP DS ; INTERRUPTS 1BH MOV DX,OFFSET CS:starthandler ; AND 23H MOV AX,0251BH ; TO MY INT 21H ; BREAK ROUTINE MOV AX,02523H ; USING DOS FUNCTION 35H INT 21H ; MOV CS:BRKVINST,1 ; SET INSTALLED FLAG POP DS installed: pop si ;***** ***** pop di mov sp,bp ; Standard exit code for c library functions pop bp ret ;***** ***** _disablebreak endp

;**************************************************************************** ;(*.PA*) ;**************************************************************************** ;* * ;* Enable break (Uninstall Break handler) * ;* * ;****************************************************************************

Public _enablebreak _enablebreak proc near

push bp ;***** ***** mov bp,sp sub sp,4 ; Standard entry code for c library functions. push di push si ;***** *****

startenable: MOV AX,CS:BRKVINST ; CHECK TO SEE IF INSTALLED CMP AX,1 ; FLAG IS SET. JNE notinstalled ; SKIP UNINSTALL IF NOT INSTALLED.

PUSH DS MOV DX,CS:OLDINT1B ; RESTORE MOV DS,CS:OLDINT1B+2 ; INT1B VECTOR MOV AX,0251BH ; TO FORMER STATUS INT 21H ; MOV DX,CS:OLDINT23 ; RESTORE MOV DS,CS:OLDINT23+2 ; INT23 VECTOR MOV AX,02523H ; TO FORMER STATUS INT 21H ; MOV CS:BRKVINST,0 ; CLEAR INSTALLED FLAG POP DS notinstalled:

pop si ;***** ***** pop di mov sp,bp ; Standard exit code for c library functions pop bp ret ;***** ***** _enablebreak endp

;**************************************************************************** ;(*.PA*)

;**** Variables used by break routines ****

_userbreak LABEL FAR BRKREQUEST DW 0 _breakset LABEL FAR BRKVINST DW 0 _oldvec6c LABEL FAR OLDINT1B DW 0,0 _oldvec8c LABEL FAR OLDINT23 DW 0,0

;**** End Variables used by break routines ****

_TEXT ends END


Dear GuyWhoReopenedTheSingletonCanOfWorms, you mentioned something about the mobs here, and alleged that I'll manage to drive you away from this wiki - it wasn't clear whose loss you think it'll be. So let me put it to you quite bluntly: you represent the mob here. You do it by the style of rhetoric you use, by the precipitation in your arguments, the sloppy phrasing, your way of throwing too many words in a page, and quite irrelevant words at that, ultimately by the way you run away from responsibility as AnonymousCoward while using a highly personal, overly assertive and bombastic style. Anonymous contributions are welcome but they strike the very wrong chord with the style that you use. Gee, and don't talk about your wife in a page like SimpletonPattern, it's not only ineffective, it's also cheesy. I know you were rushing to throw in details about your relationship with IQ and the credibility of IQ measurements, and it might have seemed important to you, but trust me that the WikiReader will yawn.

For heaven's sake, you didn't even take your time to get minimally acquainted with TextFormattingRules. No, the world doesn't go down the drain tomorrow if your righteous crusade on wiki against the evil of the SingletonPattern is not completely victorious by midnight, so please take your time and learn a thing or two about stuff like text formatting and interaction patterns, so that you can present your arguments effectively, and not with the voice of desperation. I have no intention of driving you off wiki, but you should realize that you need people like me (CriticsAreYourBestFriends), at the very least in order to refine your arguments and make them more credible, and quite possibly to learn the limits of your arguments. Take it easy. -- CostinCozianu

P.S. You may considered that wiki already contained opinions that SingletonsAreEvil and that singletons are global, and also opinions to the contrary, even before your coming and rescuing us. And RealNamesPlease may be a rather enlightening lecture.

If you don't wish to use your real name, couldn't you be GuySingleton, say? The name of this page is horribly long.


I like Singleton for one thing: a cache manager. Such a thing really should exist only once, but there is no coherent place (save perhaps at the beginning of main) to create it. Hence, singleton.


CategoryHomePage


EditText of this page (last edited August 28, 2008) or FindPage with title or text search