Skip to content

Object Obsessed Programming

In Peter Norvig’s “Design Patterns in Dynamic Programming” I stumbled over his term “class obsessed programming”. What is meant by that is having to program in a way so that everything (all verbs, i.e. functions) must belong to a class (read Execution in the Kingdom of Nouns).

Till then those language run under the term Bondage And Discipline Language for me. But OOP gets funnily ambiguous with obsession… ;-)

[Bondage And Discipline Language are] designed so as to enforce an author’s theory of “right programming” [source]

Some of those BD-languages (and their designers) realize their shortcomings and introduce new “features” to the language to work around those. That’s at least how Static classes in C# 2.0 feel like. The following quote from the linked “C# Programming Guide” almost admits it:

Use a static class to contain methods that are not associated with a particular object. For example, it is a common requirement to create a set of methods that do not act on instance data and are not associated to a specific object in your code. You could use a static class to hold those methods.

So, yeah, you could have those methods much more easily – with functions…

I – fear – those BD-lovers unleashed from that bondage will lose quite some of their discipline. Finally all those classes with static members (that quite have some odor – smelling like misunderstood object-orientedness anyhow) can be replaced with static classes. Yippee!

Don’t get me wrong – I like object-orientedness:

  • I like it, when classes are objects – metaprogramming gets easy and some DesignPatterns (e.g. Factory) extinguish. – Not that I like extinction – but succinctness
  • I also like FirstClassFunctions, ready to be called back or generally to be passed around (almost replacing the Command-pattern)
  • I like Closures (somehow reifying\’objectifying’ executional state) and the fun and enlightening things you you can do with them (e.g. read Closures + Lambda = The key to OOP in Lisp

That’s – to me – real object-orientation. Not this shallow object-thing where every idea has to be squeezed into a class.

I want freedom. I want liberty (?). I want to be able to decide whether I put on my seatbelt. Or not.

I want to ride my motorbike and get in touch.

Obsession.

Verwandte Artikel

Post a Comment

Your email is never published nor shared. Required fields are marked *