Class-orientation and Object-orientation

Mar 19, 2010 at 8:38 PM
Edited Mar 19, 2010 at 9:23 PM

One of the stimuli behind this piece of code is my perception of a distinction between a programming style which I refer to as "class-orientation" and what Alan Kay originally envisaged for "object-orientation".

In recent years, business applications are increasingly being built as more loosely-coupled systems, using dependency injection techniques, and IoC containers. This loose-coupling of classes to each other is a great benefit when unit testing, and in achieving a package/assembly-architecture which is also loosely coupled. In conjunction with Eric Evans' Domain Driven Design ideas, one can then achieve an Onion Architecture in which the _domain_ package becomes the centre of the "onion".

However, the increased power of IoC containers to construct large groups of objects with dependencies can also encourage people to tightly couple their object relationships at run-time. Inversion of Control containers allow a cascade of dependent objects to be created at run-time with very little effort. This quickly becomes a default mode of thinking for the developer, instead of considering the possibilities of dynamic object relationships, which change over the run-time of the program.

Because there is so little effort in achieving large graphs of dependent objects, programmers without sufficient experience at thoughtful OOD will often choose to construct systems which are simply groups of classes acting as logic modules, working on other classes acting as typed data constructs. Although this can be a very successful method of accomplishing a programming task, it seems somewhat removed from Dr. Kay's idea of objects, which envisions each object as a discrete machine, relating to other objects through messaging.

It is perhaps unrealistic to suggest that a strongly-typed language like C# (v.3) can be used to easily implement an authentic object-oriented design. However, from my experience, it is easy to enjoy some of the benefits of a dynamic object-oriented design by using systems such as netBoard to make the dispatch between objects more dynamic and flexible. Pairing some of the agile methods with a good OOD practice, such as responsibility-driven design, helps to approach some of OO's original goals.