Fun with Stamps. Episode 10. My stamp mental model

Hello. I’m developer Vasyl Boroviak and welcome to the tenth episode of Vasyl Boroviak presents Fun with Stamps.


One of the many problems of classic inheritance looks like this:

Classic problem of OOP class inheritance

Luckily, most of the design patterns are obsolete with stamps. Stamps solve the Animal-Robot problem like this:

Stamps’ solution to the Animal-Robot (aka Diamond) problem above

Typically, the Java and C# developers solve the above problem like this:

  • Put everything to the base GameEntity class, or
  • Use has-a composition with or without the Strategy design pattern, or
  • Use is-a composition with help of interfaces, or
  • else.

For example, in .NET they went the first way — put everything to the base class(es). The simplest UI element in .NET Framework v4.0 is System.Windows.Controls.Label.

Simple text label class hierarchy of Windows UI

According to the MSDN the class has:

  • 7 parent classes
  • 1 constructor
  • 211 methods
  • 130 properties
  • 55 events (which essentially are properties too)
  • 1 static field
  • and 1 attribute (aka annotation in Java)

A bit too much to display a simple text on a screen, right?

Another example is present in the Wikipedia “Composition over inheritance” article. It is using both “is-a” and “has-a” composition:

Looks too messy, right?

The big problem with classic OOP is that a developer should know and distinguish multiple various design patterns and specific language tricks. In other words — you better hire an experienced developer in order to have a well designed application.

I wish most of those yellow squares above were stamps, so that I can:

  • MallardDuck = compose(Duck, Quack, FlyWithWings)
  • RedheadDuck = compose(Duck, Quack, FlyTurkeyLike)
  • RubberDuck = compose(Duck, Squeak, CannotFly)
  • DecoyDuck = compose(Duck, DuckCall, CannotFly)

My stamp mental model

Those Duck, Quack, Squeak, DuckCall, FlyWithWings, FlyTurkeyLike, CannotFly and GameEntity, Biter, Barker, BatteryPowered, Killer bring some information about your future objects. I call the information THE METADATA.

Actually, the “compose” function does nothing else but simply merges the metadata of the provided stamps.

That’s it! That’s my stamp mental model!

Stamps are chunks of metadata. By merging those chunks together we can build new chunks which have the features combined.


Like what you read? Give Vasyl Boroviak a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.