Category: Software Development

  • New Python unittest module?

    Collin Winter blogs about an updated unittest module he wrote. His update fixes the internal structure, and therefore the expandability, of the module, but also cleans up the external API. There are still a few minor improvements I would like to see, but nevertheless I hope that his updated version will be included in Python’s standard library eventually.

  • Java File API

    I don’t like Java’s File API. It’s main problem is that is mixes several responsibilities into one class. One responsibility is handling of “abstract” file and path names, i.e. operating system independent file names. The other responsibilities are all file system related: Querying file meta information (access rights, access times, file type), creating files, and listing…

  • Java: Iterators are not Iterable

    This is something I stumbled across multiple times now in Java: Iterators are not Iterable. Java 1.5 introduced the foreach statement, which allows easy iteration over collections like this: for (MyClass item: myCollection) { doStuffWithItem(item); } For this to work class MyClass must implement the Iterable interface. This interface defines just one method that returns an Iterator: Iterator<T> iterator(); This works fine in many cases.…

  • JavaScript Includes Revisited

    I’ve given in in the JavaScript and Modules matter. I’m doing now what all the cool kids are doing: Using XMLHttpRequest synchronously to load external JavaScript files. This has the advantage that it works synchronously, a very important thing for includes. Therefore I don’t need callback and moduleLoadedhackery anymore. Also I have sensible error checking, i.e. I can notice…

  • Porting JavaScript to Internet Explorer

    While porting a small AJAX application I wrote to Internet Explorer, I encountered a few problems: IE doesn’t like <script> tags without a matching closing tag. This is especially a problem if you use the src attribute and try to use an XHTML-like closing tag like this: <script src=”…”/> In this case IE doesn’t draw anything at all, since…

  • Apache, cgi-bins, and the Authorization header

    I had a problem: Server A runs a web service, which requires users to authenticate using the standard HTTP authentication mechanism. Server B should have web pages that use AJAX to query A’s web services. Server B’s web pages also require authentication, using the same scheme, backend and database as server A. There are two problems:…

  • Loading Modules in JavaScript

    One of the weaknesses of the JavaScript language is that it does not have the concept of “importing” or “including” other source files or modules. In client-side JavaScript as used in web browsers you have to include all JavaScript files you intend to use in the main HTML file like this: <html> <head> <title>…</title> <script…

  • PyUnit and Decorators

    One of the shortcomings of the Python standard library is in my opinion that PyUnit doesn’t use decorators (as later versions of JUnit and NUnit do). Therefore I have written a sample implementation that adds decorator support. (unittest.py; diff to Python 2.5’s unittest.py) To do: Warn when old-style and new-style tests are mixed. Throw an exception when multiple setup or teardown methods exist. Ability…

  • Porting Tomboy from C# to C++

    Hubert Figuiere writes about porting Tomboy from C# to C++. I tried to leave a comment in his blog, but something doesn’t work, so here is my comment: Porting Tomboy from C# to C++ seems like a step back to me. C# is a higher level language than C++ and is much easier to write good and clean…

  • XML Test Runner for PyUnit

    JUnit features an XML Test Runner. This means that the result of a test run is not written to stdout, but instead written into an XML file. This XML file can then be automatically processed. This is for example useful for fully automated builds using software like CruiseControl. The XML output is easily converted into an XHTML…