How intuitive is object-oriented design?
This post is also available in: Nederlands (Dutch)
A recurring discussion is about the intuitiveness of object-orientation and its perceived complexity. Articles in authoritative magazines like the ACM Communications are also wrestling with this “intuitiveness”.
This article struck me as especially interesting because it involved a multidisciplinary approach involving cognitive psychology, in particular the Dual-Process Theory, to research the thinking processes of object oriented modellers.
First a little about the Dual Process Theory. I found it quite interesting to see it mentioned here in this article, because it relates to several researches I have done in the past, in particular the theories of Gurdjieff which influenced me heavily. I got in touch with Gurdjieff’s ideas, like most people, by reading a book by his best known pupil, P. D. Ouspensky, In Search of the Miraculous, in which Ouspensky describes in an autobiographical style his encounter with Gurdjieff.
Another book by a Dutch psychologist, Peter Warnaar’s Psycho-Analysis of Altered Consciousness (Psycho-analyse van de bewustzijnsverandering) based on this his theory of three “kinds” of thinking:
As Gurdjieff explained it, these three kinds of thinking have completely different “speeds”, with mental, rational thought being the slowest, and emotional and physical each an order of magnitude faster. In the context of dual-process theory my interpretation is that mental thinking would be analogous to System 2 or S2 thinking, and emotional to System 1 or S1 thinking.
Now back to the subject of this article. The research reported several examples of hasty, almost automatic, design decisions done by the S1 thinking processes in designers (the group researched consisted of designers with 2-12 years of experience in OO). The first example in the article is about Confusing the direction of inheritance. The second, a little more revealing in my opinion, was about Difficulties in identifying objects. A small class diagram was provided:
This is a very elementary class diagram, but already it is revealing interesting thought processes.
The client logs in, the server validates the user. This is completely “intuitive”, almost a transcription of our natural language way of describing the process.
There is a discussion between two participants working on this model. Both exhibit S1 thinking, but each has a different approach.
One, called Ron, is convinced Login and Register should be modelled as objects.
The other, called Sharon, has problems with his proposal, because it “feels not good”.
Both have considerable difficulty expressing their reasoning.
Ron assures Sharon: “don’t worry, it will be okay”. And Sharon complains about how it feels to her.
However it creates complexity where it does not need to be. The Active-Passive pattern has not been applied. What would be the result of applying this pattern?
The method ValidateUser would have been placed in the Client class: the client is responsible for validating himself – this would make the server simpler (almost only a container of users).
I assume this would feel ok to both Sharon (it is a method) and Ron (it is a cohesive set of responsibilities).
The validation process itself would be a candidate for delegation: create a Validation class that is private to the Client to do this. This is a reasoning process which is seldom taught at schools and universities, or on courses in OO. However it is extremely simple and would help in providing both Ron and Sharon with a firm foundation for both S1 and S2 thinking – because I am convinced only the seamless cooperation between the two (or as I see it, three) modes of thinking result in high quality models that reap the benefits of the power of object-orientation. Benefits that I fear I must conclude, are hardly never reaped because of fundamental misconceptions about the nature of OO, and a widespread ignorance about what OO actually is.
To conclude, I think that being aware of the different modes of thinking can be very valuable in learning OO or for that matter any method or theory. Also I have argued elsewhere that there may be “tricks” or mnemonics that can help in bridging the gap between these modes of thinking. Finally, the fact still remains that internalising knowledge (which is the path to wisdom, or in the case of modelling, mastery) is a lot of work and requires time, effort and talent.