OOP

Composition vs. inheritance

Today in an interview I was asked, when would you use composition and when would you use inheritance? I struggled with this question, not because I have never considered it, but because the interviewer was asking me to translate abstract Read more…

By kryptx, ago
.NET

Guaranteed Deadlock

There was a thread on StackOverflow recently about an interview question where the candidate was asked to write a program that will always deadlock. Eric Lippert’s example is shorter than mine, but I think my answer (which I’m posting here Read more…

By kryptx, ago
.NET

Connected Layer, a little deeper

If you're working frequently with the connected layer, the previous post would be sufficient for most purposes (given adequate knowledge of SQL), if perhaps a little awkward. The following information might make your life a little bit easier. (more…)

By kryptx, ago
Uncategorized

Extension methods

Extension methods are methods that are added to existing compiled types. These are useful for adding new members to classes in the BCL or in assemblies for which source code is not available. However, extension methods can also be useful because they can be called on null references. For instance, an immutable Stack(of T) implementation might contain a head of type T and a tail of type Stack(of T). How do you create an empty stack if T is allowed to be a non-nullable value type? (more…)

By kryptx, ago
.NET

Comparing reference types

When comparing two instances of a reference type for equality (in value, not checking to see if they are the same instance), rather than using .Equals it’s best to use an IComparer. In a generic type, if nothing is known Read more…

By kryptx, ago