Sometimes, the human mind acts in mysterious ways
What follows is quite embarrassing actually. Yesterday, I was reviewing my own code and optimizing it a bit, looking for ways to make it even more generic, adding more constructors for ease of use, you know the whole 9 yards. In the O/R mapping layer which is targeted by the generated code of LLBLGen Pro, the application I've been working on for the last 5 months, I use a dynamic query engine (DQE). This DQE is specific for each database vendor so you have a special DQE for SqlServer, one for Access etc. The DQE constructs query objects which contain a command object, the parameters and all other necessary objects and data to get the query executed. All methods are static.
"Oh!", my mind sighted. "It is a generic piece of code, and to enforce a common interface of methods, we should define such an interface!". I wrote the SqlServer DQE code, which I was looking at, five weeks ago if not more, so the suggestion of my mind wasn't that bad indeed, but I was immediately wondering why I hadn't done it already. I defined the interface but as I soon found out, static members can't be part of an interface. My mind was outraged. "Why is this!", it fumed. "How am I suppose to enforce a given interface onto developers of DQE's, if I can't define such an interface in the first place!".
I had to agree with my mind this time. It was kind of odd, the only way to enforce an interface on developers was by defining that interface and now I couldn't. My mind was still calling the C# language designers all kinds of names and not in the mood for any reasoning so I decided to hop into a thread in the C# newsgroup which was about that same subject: static methods in interfaces and why you couldn't define them in interfaces.
The C# newsgroup has some 'regulars' and one of them is Jon Skeet, who also knows a lot about Java. He simply said "But the only way you can call these methods is by reflection anyway!". I thought... wait a minute. "MIND! Come here!", I cried. With its tale between its legs and an ashamed look in its three green eyes, my mind shambled towards me. "Why didn't you think of that and stopped me before I made a fool of myself on usenet?" It didn't answer. All it could produce were soft mumbled sounds.
Yeah, why didn't I think of that? How are you suppose to call a static method on an interface if you use that interface, say IFoo, to make your code be able to handle multiple implementations? You can't. It's illogical to call IFoo.Method(), because which implementation of IFoo do you mean?
It's a weird thing, the human mind. It makes you stare at material you have to work with for hours in a row without noticing the reason why you keep on wondering: "Why isn't this possible?".