Home > Programming > The World is not Hierarchical

The World is not Hierarchical

One of the reasons why roles could turn out to be a fundamentally better way of doing OO is that they allow classes to be organised in a non-hierarchical way.

As chromatic said in Perl Roles versus Interfaces and ABCs:

This works great when you can model all of the entities in your program in a singly-rooted hierarchy. Many simple programs do this effectively. As the difficulty for creating sane biological taxonomies indicates, the real world does not lend itself to such artificial simplicity.

It’s worth remembering that when we’re writing classes, we’re actually modelling the real world (or attempting to). Sometimes that modelling is very abstract (in the sense that it seems very far removed from what we’re actually trying to model), but each class is a cog in the software machine that we’re building, a machine that (hopefully) produces real output from real input.

The world itself is often not hierarchical. It tends to be a lot more complex, with relationships going in many different directions. So it seems intuitive that modelling in a non-hierarchical way will produce better results. Of course, there are hierarchies in the real world too (middle management wouldn’t exist without them), but roles give us a more complete modelling toolbox.

It’s no coincidence that the IT world has moved from Hierarchical to Relational databases, or that a lot of people now prefer to organise large sets of documents with tags rather than categories. It may turn out that roles are an equally significant step forward in the world of OO.

Categories: Programming Tags: ,
  1. May 10, 2009 at 7:10 pm

    > It’s worth remembering that when we’re writing classes, we’re actually modelling the real world (or attempting to).

    Actually, the approach “have a small, lean, abstract” class system and use roles for everything else is also the approach taken by the ontology people.

    So it is good to see that more people are moving in this direction.

  2. james
    May 12, 2009 at 2:15 pm

    don’t tell this to the CouchDB/XML|JSON blob store in database people.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: