Thursday, May 04, 2006

The Liskov Substitution Principle

As Ordina is working on new C# 2.0 coding guidelines, last week I had a discussion with a colleague on object-oriented design. One important principle is the Liskov Substitution Principle which in a C# context is often written as "methods that use references to base classes must be able to use objects of derived classes without knowing it." I had quite some troubles explaining what it is really about, so I dug up an old (10 years) article written for C++ that still applies to modern-day languages. In fact, it also touches the subject of Design by Contract, another interesting principle that few use these days.