Skip to main content

Posts

Local Builder Pattern Broken in Java?

Time and again, when I want to break up a longish Java method into smaller parts, I find myself wishing back the by-reference parameters and access to surrounding local procedure variables of Pascal. Now, I know that the discipline of trying to always pass all required arguments explicitly, and to not rely on changes to by-ref params is often helpful. Nevertheless, sometimes it gets in the way. One fairly clutter free approach to get Pascal's features back goes like this: public interface LocalBuilder { T build(); } and then: public MyClass computeIt() { new LocalBuilder () { final int input1 = ...; final int input2 = ...; int state1 = ...; int state2 = ...; public MyClass build() { stepOne(); stepTwo(); return result(); } private void stepOne() { ... } private void stepTwo() { ... } private MyClass result() { ... } }.build(); } While this basically works, it has a few problems: Exceptions thrown by build() must be declared already on th...

Documentation Driven Development - Other Takes On The Theme

I googled for "Documentation Driven Development" and came up with a number of links (why the heck did I not do this sooner?). SpliceIt seem to be doing it, but don't cite tests. There is no mention of integration with use-case-level tests. Vincent Massol had the experience when writing books about frameworks - always improved the underlying code. The message is: you have to be serious about writing good docs. Otherwise the effect is lost. Korby Parnell just thinks about it, but some comments point to people with experience doing it. IEEE has an article about DDD for real time systems. Also seems to take it as far as code-generation. I haven't read it. Miguel dos Santos has little to add, but there is a nice comment by someone called "Tania" about applying the idea of documenting the "why" more generally. In the groups , I got: Ilja Preuss 's take is a bit too limited for me. In my experience, good DDD docs focus on tasks, not classes and...

Impressions: "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries"

I've recently read Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries by two lead architects on the .NET Framework. A mixed experience, I have to say. The book does offer good advice, but somehow, hardly anything seemed truly new. Maybe that is because I've already read Josh Bloch's Effective Java , but, I suspect, mostly because I have accumulated a fair bit of framework design experience myself (and, like them, learned from many mistakes). It was quite eerie at times, as it felt like they'd written down my own thoughts. So, it has still been a rewarding read, seeing as this eminent source confirmed a lot of my design creeds. A lot in the book is quite .NET specific, though I can hardly blame the book for that. And while it is tedious reading to someone looking for higher-level insights, I still wholeheartedly agree with the authors that consistency down to detailed naming conventions matters a lot in framework design. The most g...
Because I am now reading a book about Haskell, but also because when I implemented the gist of Palo in Erlang , I was bitten by - tada! - a typing error, I decided to port the code over to Haskell. While the functional core syntax of the two languages is quite similar, here's one detail that took me a while to figure out: A case construct in Haskell always introduces new name bindings, whereas Erlang uses existing bindings as equality tests. So, in Haskell you have to do something like if atkey == key then ... else ... , while in Erlang you can simply do case AtKey of Key -> ... Other -> ... (which seems more intuitive to me).

The Gist of Palo - Erlang In Action

I have been asked to review the Palo code base. This is an open-source MOLAP database server. To get a feeling for what its core C code does, I reimplemented the gist of it in Erlang. Turns out it's really just a few lines when you have high-level functional constructs at your disposal. Out of curiosity, I then went and extended it so it really mimicks the Palo cube storage more closely, binary array searches and all (loading is still non-optimized, though). Finally, I even added a tweak that I suspect would boost Palo's performance a little. If anyone's interested, the code for loading and finalizing a cube is in cube_load.erl , the basic code for querying - possibly aggregated - cell values is in cube.erl . The latter also contains some tests showing how it's used.

Meta-data Enhanced Wiki

I recently stumbled upon Diamond Wiki . This is a wiki enhanced by meta-data and navigation along meta-data dimensions. Interesting. Maybe a first step in the direction of something like an ad-hoc database. While deeply impressed with DabbleDB , I still think it should be possible to come up with something even more fluent, more ad-hoc .

DDT - Documentation Driven Testing

What JCite really is about is what I am going to call DDT: documentation-driven testing. It is a discipline that complements and, during the conception of an API, really comes before TDD: test-driven development. DDT weeds out them design bugs! :)