How Not To Use OOP

Richard Tallent points to an example of absurd OO practice. I think that this speaks more to the usefulness of agile practices than good design. If you're following the principle of the simplest thing that could possibly work, then the first example is it. As the program grows, you refactor, and you might end up with the "good OO" result after enough time. Richard's right, to promote good practice, the result needs to look better than the supposedly wrong implementation. Suppose you needed to do detection on 30 different OSes, or discriminate between versions of OSes - which looks better, a 90 line case statement, or a class factory? Well, I like Simon's solution even better, but if Java is a requirement, that's probably out of the question. What about something reusable, and not meaning from the command line? Again, if you're in Java, main isn't the place to start if you want that.

Richard has a bunch of good posts today, so I'll keep going. Focus Thieves hits a topic that's been on my mind a lot lately. I absolutely despise splash screens, and I've been using PLT Scheme and Eclipse a lot lately, which are both slow to load and try to cover up that with a splash screen. How about putting an indication on the task bar or task tray that the program's loading, instead of taking over the screen. The absolute worst offender is a splash screen that takes over focus and won't let go. But while on the subject, developers have gone task bar / task tray (I know that's probably the wrong term) crazy, particularly developers of consumer products. My computer at home has crap in the task tray for the printer, scanner, digital camera, and about 17 other things. It used to be that software vendors thought they owned the desktop and start menu, but it's positively malignant now. Every option that MS creates for launching or accessing an application gets glommed on. MS has bandaids like the hidden task tray in XP, but maybe more extreme measures are needed, like asking the user if they'll allow a program to put up a task tray icon. I need to read the paper Richard referenced. If I didn't know better, I'd say that Richard is a closet functional programmer ;-)

Finally, I don't remember where I ran into this, but I found a discussion of implementing refactoring in Ruby. The author is looking to the Smalltalk refactoring browser for guidance, and it's very interesting. An excerpt:

Now, the tactics (for something like a rename operation). When they refer to "the wrapper", that's part of the tool, and when they say "the program" here, they mean YOUR code: "As the program runs, the wrapper detects sites that call the original method. Whenever a call to the old method is detected, the method wrapper suspends execution of the program, goes up the call stack to the sender and changes the source code to refer to the new, renamed method."...So they assume you have a unit test suite with 100% coverage. If you wrote your code strictly test-first, you should have that. But that's a pretty high bar. Any missing tests will cause the refactoring to create code that doesn't work correctly, and (because you are missing a test) you won't realize it until you run the app and hit that particular case.

Finally, thanks to Bill Clementson's comment, I've taken the plunge with Emacs. One thing I'd like to know is if there's FTP support built into Emacs - right now, my posting API is FTP and it'd be nice to have it all integrated into one app.

— Gordon Weakliem at permanent link

Comments

How Not To Use OOP

> One thing I'd like to know is if there's FTP support built into Emacs



Hey, everything is built into Emacs ;-)



Search the Emacs manual for "ange-ftp"



--

Bill Clementson

Bill Clementson at

comments are now closed on this post