Hell is other people's code

Jean-Paul Sartre famously wrote:

Hell is other people.
(L'enfer, c'est les autres)

(From his 1944 play No Exit, original title Huis clos.)

Every programmer who has ever inherited a codebase knows the programmers' version of it:

Hell is other people's code.
— michael.gr

C# methods you are better off never calling

Some methods in .NET are like landmines: they lie in plain sight, they look harmless, and the compiler lets you step right on them.

Two of them are object.ReferenceEquals(object, object) and object.Equals(object). Both accept arguments of type object, which means that they accept any arguments at all, even arguments for which the answer can only ever be false. The compiler does not issue an error about such invocations, not even a warning, which is something that I, personally, find preposterous.

This post shows how you can get the compiler, or at least Visual Studio, to point out such mistakes.

Read more »

CS0809: Obsolete member overrides non-obsolete member

C# compiler warning CS0809 "Obsolete member overrides non-obsolete member" exists to tell us that marking an override as [Obsolete] is pointless. The warning is essentially saying that if you add the [Obsolete] attribute to an override, hoping to see diagnostics on invocations of that override, you will be disappointed, because there will be none, due to the way the compiler works.

However, contrary to what this warning is trying to say, I am here to tell you that adding [Obsolete] to an override is not pointless; it is actually quite useful. Read on to see why it is useful, and why you should therefore suppress warning CS0809.

Read more »
(1 - 47)
Enter Press Enter to jump