Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by email or phone:


+972 52-548-6969

, @ Q j

Posts: 6,633 | Comments: 48,370

filter by tags archive

Paul Graham On Software Patents

time to read 2 min | 254 words

Paul Graham has a great article (as usual) about parents, which contains the following quote, that got a bona fide Laugh Out Load from me:

...when you're saying something that Richard Stallman and Bill Gates would both agree with, you must be perilously close to tautologies.

This is nice as well:

Instead of the canonical "could you build this?" maybe the corp dev guys should be asking "will you build this?" or even "why haven't you already built this?"

The nicest part is at the very bottom, but it has a comment that has all the sentiments of a slashdot reader:

If they [big business] agreed among themselves never to do business with any firm employing anyone who had worked for a patent troll, either as an employee or as outside counsel, they could probably starve the trolls of the lawyers they need.

I must say that I agree with this sentiment, although I don't see how enforcable this is.

Testing UI - A Challange

time to read 2 min | 254 words

Here is the story:

When the a node in the graph is hovered via the mouse, a connection point (a node can have several) is made visible, and the user can drag the connection point to another node (when it enter the second node, the second's connection points will be visible) and create a connection between the two connection points. A visible line should exist when dragging the connection, and after it was attached it should be permenantly visible.

I got this to work without tests, since I just can't think of how to test this stuff. Right now I'm heavily using the functionality that Netron provides (which does 96% of the above) and the implementation uses windows events and state tracking quite heavily to get this functionality.

I suppose I can try to refactor the logic out so it would be testable, but that would mean duplicating the events structure for WinForms. In addition, I can see no way to test that the correct stuff is drawn to the screen and I am not fond of taking a screen shot and then comparing the known good to the result on a bit by bit basis. If for no other reason than that I can think of several dozens of tests for the functionality that I need.

Any suggestions on how to test this?

Testing UI, Again

time to read 2 min | 320 words

I’m testing UI again, and I guess that it is going to suck this time as it did before. This time I’m using Netron for the graphs, and it’s not that bad this time, mainly because I can get into the guts of Netron and change it, and this make all the difference in the world.

The problem with that is that while Netron is a library for graphs, it is mainly for painting graphs, so it got a boat load of baggage that I don’t need when I’m doing testing. I started using the Pass Null pattern, but there seems to be lot of stuff that just can’t accept null (and doesn’t check for it).

I didn’t look too deeply into the way Netron is structure, I admit, mainly because there is quite a bit of GDI stuff that I just don’t want to get into, but I guess that I’ll have to, at least to rip out the parts that I’m not using and don’t want to maintain. The main problem I’ve with Netron is that it needs to keep a lot of state, which makes life hard when you try to understand what is going on around you. The framework is there to help you build really complex stuff, but I managed to scale it down without much trouble.

I just realize that I can just use the whole thing for testing without bother the UI bits. This mean deleting my façade code (always a pleasure) and using the real thing, and it doesn’t affect the way I’m working with the model.

All things aside, Netron looks really good, check out the sample applications screenshots. I managed to get a working sample that looked about as good as Microsoft’ Class Designer in no time, and Netron takes care of most of the details with regard to object movement, highlighting, connecting the dots, etc.


More on the .Net Framework

time to read 1 min | 81 words

Can someone justify when I get those types in the System namespace? (from the System assembly)


  • NewsStyleUriParser  
  • GopherStyleUriParser
  • Etc..



I mean, I get that networking is important but isn’t putting NNTP and Gopher(??) in the System namespace too much?

More Rants about .Net Design

time to read 1 min | 143 words

There are way too many places in the class library that are internal without cause. The entire ASP.Net caching system is one big internal block, and the Compression namespace has only two public members.

I need to read just the header of a zip file, as far as I can see, this is certainly possible using the classes in the framework, but they are all marked internal, so I have no way in short of using Reflection.

I get the issues with the testing matrix, and the possible backward compatibility issues that may happen when developers use stuff that you may want to use. But the documentation contains quite a bit of classes where the only documentation is “This class is for the framework internal use only” which should be warning enough for developers that they may change without warning.

Ranting About Design: System.IO.Compression.GZipStream vs. ICSharpCode.SharpZipLib.GZip.GZip*Stream

time to read 2 min | 252 words

I had a change today to look at the implementation of both classes, and I really don’t get what went through the minds of the developers in Microsoft when they wrote this class.

To be (brutally) short, GZip is a derivative of the Deflate algorithm with some additional headers tucks on it. This seems like an ideal case for inheritance, put the Deflate algorithm in its own class, and then put the GZip handling in a derived class.

On the surface, this is what both Microsoft and #ZipLib did, but I took a look inside today with Reflector and found that System.IO.Compression.GZipStream is nothing but an empty shell around DeflateStream. I mostly expected that, but I was very surprised to see that no where in GZipStream there was handling of the  GZip headers.

Looking a little deeper, I found this constructor:

internal DeflateStream(Stream stream, CompressionMode mode, bool leaveOpen, bool usingGZip)


It makes the OO developer in me cringe in pain. Why would they do that? This means that the DeflateStream needs to knows about its children, that it has specialized behavior for one specific child, etc. This is just wrong.

The #ZipLib got classes that actually have behavior, by the way. That is, the child class extend the functionality of the base class. This sounds familiar, I wonder where I heard those before…

The return of PVOID

time to read 1 min | 103 words

I think that the Daily WTF should be required reading for developers. I don't believe that I would have ever thought about using the language like that. Check out the Vector Oriented Programming, or the really dynamic typing, sure to bring tears to the eyes of old timers around the world. It combine hard coded indexes, random data types and the familiar sense that you need to remember the manual by heart (and memorize a passage each day, lest you start to forget) before you can do hello world in the system.

In summary: WTF!?!

Null Method Invocation

time to read 5 min | 948 words

About 6 months ago I left a comment here, and I returned now to check it, and found a real gem. Check this out, it is about invoking methods on null, like this:

Foo foo = null;

 Wesner Moise explains what the possibilities are:

... An instance method can treat an null in special, default way to maintain continuity with nonnull objects and eliminate the need for callers to perform null checks. One example of this is how it simplifies the manipulation of binary trees. It's similar to the null object pattern, with the null object being null.

I can certainly think of several ways that this would be nice to use. It was removed from C# by the ECMA during the standardization process. It may be a good thing, I don't know if stuff like this are good (because they open up possibilities) or bad, because they mean more stuff to care about. Anyway, I'm not sure that I would ever want to see something like "if (this == null)" in my code any time soon.

One thing to note, this is supported by the CLR. C# will emit a callvirt IL call, which will cause a null reference exception, but this IL works just fine with no exceptions ( showing just the call, see the C# source below):

.method public hidebysig static void             Main        (string[] args) cil managed
      .maxstack 1
      .locals init ( TestNullMethodInvocation/Inner inner1, bool flag1)
      L_0000: nop     
      L_0001: ldnull
      L_0002: stloc.0
      L_0003: ldloc.0
      L_0004: call instance bool TestNullMethodInvocation/Inner::InstanceMethod()
      L_0009: stloc.1
      L_000a: ldloc.1
      L_000b: call void [mscorlib]System.Console::WriteLine(bool)
      L_0010: nop
      L_0011: ret

This translate to this C# call (except for the call vs. callvirt, of cours):

using System;
public class TestNullMethodInvocation
 public static void Main(string[] args)
  Inner inner = null;
  bool result = inner.InstanceMethod();
 public class Inner
  public bool InstanceMethod()
   return true;


  1. I WILL have order: How Noise sorts query results - about one day from now
  2. Reviewing the Bleve search library - 2 days from now
  3. I WILL have order: How Bleve sorts query results - 3 days from now
  4. I won’t have order: Looking at search libraries without ordering - 4 days from now

There are posts all the way to May 31, 2018


  1. I WILL have order (3):
    25 May 2018 - How Lucene sorts query results
  2. RavenDB 4.1 features (4):
    22 May 2018 - Highlighting
  3. Inside RavenDB 4.0 (10):
    22 May 2018 - Book update
  4. RavenDB Security Report (5):
    06 Apr 2018 - Collision in Certificate Serial Numbers
  5. Challenge (52):
    03 Apr 2018 - The invisible concurrency bug–Answer
View all series



Main feed Feed Stats
Comments feed   Comments Feed Stats