fredag 19 november 2004

A Prompt You Can Stand

For the past four years, Windows has been a very sophisticated operating system. It has provided stability, efficient pre-emptive multitasking, solid memory protection, POSIX compatibility, an acceptable (though unimpressive) file system, good multi-user support and increasingly good development tools (Visual Studio is truly fantastic nowadays).
However, one aspect where Windows comes short of its free competition is its command shell. Windows always had some level of support for batch files, but not the wealth of command line tools to fully exploit automation. In addition, the shell interface is horrible. The configuration settings are limited, and the window width can not be dynamically changed. Having briefly played with the betas of Microsoft’s next generation shell, codenamed Monad or MSH, it looks like the user interface will continue to be poor for the next few years even though scripting capabilities will be fantastic.
However, there is a better alternative available. Cygwin, a popular port of Unix scripts, APIs and tools, provides Windows users with the power and convenience of traditional Unix tools like grep, and an alternative command terminal that can host bash.



Personally I have found this to provide a good alternative to the standard Windows command prompt. You get a highly responsive terminal, with tab completion and history, and the ability to change the window size whenever you want to. All of the Unix tools that you expect are here (or can be automatically downloaded). Some of the downsides that I have found include a really ugly non-standard scrollbar, and an inability to drag files onto the shell from Explorer to automatically obtain their path. Some people even run GNU/Emacs in this environment. I tried the same, but noticed that the bottom-most line would disappear. Very annoying.
All in all, I have been happy to trade my dusty old MS-DOS prompt for a shiny new bash prompt.

måndag 8 november 2004

Review: Design Patterns

For the past three years or so, I’ve been hearing increasingly more about software patterns. Some regard them as the best thing since sliced bread. If you dig through the hype, you will find a clever way of describing common software constructs in a de-facto standard vocabulary with which an increasing number of software developers are familiar.
If you have any experience with software development, you probably at some point devised a mechanism by which interested object instances could register to receive events emitted by other objects. If you’re anything like me, you probably did not know at the time that you were actually implementing a variant of the Observer pattern. Similary, you may have created a class returning new instances of appropriate subclasses of abstract objects without knowing you were using the Abstract Factory pattern. And you may not have known that the iterators of the C++ Standard Template Library were designed around a pattern later to be known as the Iterator pattern.
As with most new software development methodologies, patterns were — in my view — excessively hyped for a period. Now that things have calmed down, it is possible to evaluate patterns on their own merits — and those merits do not necessarily constitute providing revolutionary new design principles. Rather, they provide a way to express common programming constructs in a language-independant way, which must be a Good ThingTM.
If you have somehow missed the patterns hysteria and would like to get into it, I really recommend the excellent book by Gamma (as well as Helm, Johnson, and Vlissides), one of the authors who pioneered the concept (and who later created the very useful JUnit unit testing framework).
The book provides a useful summary of all established patterns on the first few pages, and then goes on in subsequent chapters to explore each pattern in great detail, providing examples and plenty of motivation for the design decisions made. This book is the reference to software patterns and you should probably consider getting one for your bookshelf.
If you prefer a more concise summary, there are some excellent pages available on-line that provide just that — in Microsoft’s excellent C# language, no less.