C#'s greatest mistakes

Roman Ivanov isroman.DEL at ETE.km.ru
Sat Nov 27 10:55:15 PST 2010


On 11/26/2010 10:27 PM, Andrei Alexandrescu wrote:
> http://oredev.org/2010/sessions/c-s-greatest-mistakes
> 
> Andrei

The static interfaces the presenter speaks about make sense, but they
are a kind of a hack at the same time. To me it seems that the two
underlying problems are:
1. Classes with static methods and attributes should behave more like
normal objects. (WE want to constrain them by interfaces, pass to
methods, maybe even use inheritance.)
2. Constructors should behave more like static methods. (Again, we want
to be able to reason about them inside interfaces.)

For example:

class DynamicGetter : IGetter{
    int getValue(){
    }
}

static class StaticGetter : IGetter{ //doesn't work, but probably should
    static int getValue(){
    }
}

SomeObject.someMethod(new Dynamic()); //this is allowed

SomeObject.someMethod(StaticGetter); //this is not allowed, why?

Classes can contain static data and methods, so why they behave so
drastically different from normal objects?


More information about the Digitalmars-d mailing list