Application 1 – Analysis and Synthesis of Prior Research
HOW INTUITIVE IS OBJECT-ORIENTED DESIGN?
By Irit Hadar and Uri Leron
Intuition is a powerful tool that helps us navigate through life, but it can get in the way of more formal processes.
T he object-oriented programming paradigm was created partly to deal with the ever-increasing complexity of software systems. The idea was to exploit the human mind’s natural capabilities for thinking about the world in terms of objects and classes, thus recruiting our intuitive pow- ers for building formal software systems. Indeed, it has commonly been assumed that the intuitive and formal systems of objects and classes are similar and that fluency in the former helps one deal efficiently with the latter. However, recent studies show that object-oriented programming is
quite difficult to learn and practice [1, 3, 7]. In this article, we document several such dif- ficulties in the context of experts participating in workshops on object-oriented design (OOD). We use recent research from cognitive psychology to trace the sources of these difficulties to a clash between the intuitive and analytical modes of thinking.
COMMUNICATIONS OF THE ACM May 2008/Vol. 51, No. 5 41
Hadar_ lo:Intro_ lo 4/28/08 3:05 PM Page 41
42 May 2008/Vol. 51, No. 5 COMMUNICATIONS OF THE ACM
Recent research in cognitivepsychology shows that peo-ple consistently make mis-takes on simple everydaytasks, evenwhen the subjectsare knowledgeable, intelli-gent people, who undoubt-edly possess the necessary knowledge and skills to perform correctly on those tasks. The source of these mistakes is often shown to be the insuppressible influence of intuitive thinking. This research, the heuristics and biases program, has been carried out byKahneman andTversky andoth-
ers during the last 30 years, and has led to Kahne- man’s receiving the 2002 Nobel Prize in economics.1
In his Nobel Prize lecture, Kahneman opened with the following story:
Abaseball bat andball cost togetheronedollar and 10 cents.Thebat costs onedollarmore than the ball. How much does the ball cost? Almost everyone reports an initial tendency to
answer “10 cents” because the sum $1.10 separates naturally into $1 and 10 cents, and 10 cents is about the right magnitude. Indeed, many intelligent people yield to this immediate impulse: 50% (47/93) of Princeton students and 56% (164/293) of students at theUniversity ofMichigan gave thewrong answer [2, 4].
What are our mind’s mechanisms that may account for these empirical findings? One current influential model in cognitive psychology is Dual- Process Theory [4, 10, 11]. According to this theory, our cognition and behavior operate in parallel in two quite different modes, called System 1 (S1) and Sys- tem 2 (S2), roughly corresponding to our common sense notions of intuitive and analytical thinking. These modes operate in different ways, are acti-
vated by different parts of the brain, and have differ- ent evolutionary origins (S2 being evolutionarily
more recent and, in fact, largely reflecting cultural evolution). S1 processes are characterized as being fast, automatic, effortless, unconscious, and inflexible (difficult to change or overcome). In contrast, S2 processes are slow, conscious, effortful and relatively flexible. Inaddition,S2 serves asmonitor andcriticof the fast automatic responses of S1, with the “author- ity” to override them when necessary. In many situa- tions, S1 and S2 work in concert, but there are situations (such as the ones concocted in the heuris- tics and biases research) in which S1 produces quick automatic non-normative responses,while S2mayor may not intervene in its role as monitor and critic. A brief analysis of the bat-and-ball data can
demonstrate the usefulness of dual-process theory for the interpretationof empirical data.According to this
theory, we may think of this phenomenon as a “cog- nitive illusion” analogous to the famous optical illu- sions from cognitive psychology. The surface features of the problem cause S1 to jump immediately with the answer of 10 cents, since the numbers one dollar and 10 cents are salient, and since the orders of mag- nitude are roughly appropriate. The roughly 50% of students who answer 10 cents simply accept S1’s response uncritically. For the rest, S1 also jumps immediately with this answer, but in the next stage, S2 interferes critically andmakes thenecessary adjust- ments to give the correct answer (five cents). Recently, a similar phenomenonhasbeen found in
advanced mathematical thinking, with college stu- dents learning abstract algebra [6]. While it seems natural that people in everyday situations prefer (however unconsciously) quick approximate responses that come easily to mind over careful sys- tematic rule-bound reasoning, students solvingmath- ematical problems during a university course would be expected to consciously train theirmethodological thinking to check, and override if necessary, their immediate intuitive responses. From these findings we may understand the strong influence intuition, especially its tendency to be influenced by surface clues, has on our thinking. In this article we demon- strate that a similar phenomenon—and a similar explanation—may also hold for OOD tasks carried out by experts in industry. Anote on terminology:We followKahneman and
While people in everyday situations prefer responses over careful systemic reasoning, students solving mathematical problems would be expected to consciously train their methodical thinking to check, and override if necessary, their immediate intuitive responses. From these findings we may understand the strong influence intuition.
1Tversky unfortunately died several years earlier.
Hadar_ lo:Intro_ lo 4/28/08 3:05 PM Page 42
other cognitive psychologists in using “intuition” in its folk meaning of everyday thinking. This meaning is elaborated in the description of System 1, and is mainly used in contradistinction to analytical think- ing or to reasoning. The title of this article should thus be understood as an inquiry into the nature of the gap between the everyday “natural” meaning of objects and categories vs. their formal meaning in OOD. It should further be noted that intuition may have different meanings in different contexts. For example, our use of the term is quite different from the way a mathematician might use it when he or she says: “I had the intuitive idea of the proof long before I was able to complete the formal proof.”
INTUITIVE THINKING IN OOD OOD is a complex domain, requiring formal train- ing and effortful thinking, which is just the kind of process System 2 would be expected to appropriate. However, our research indi- cates thathere too the auto- matic, quick, and effortless operation of System 1 may hijack software developers’ attention and lead them to decisions that are not ade- quate and may even clash with their own knowledge. We discuss several exam-
ples of this phenomenon exhibited by experienced software developers in industry while practicing designactivities, andexplain themin lightof thedual- process theory. We invoke this theory in the domain of OOD in an attempt to understand the relatively elementary mistakes we observed in the responses of intelligent capable professionals, even in cases when they have the necessary knowledge to avoid suchmis- takes. Our observations took place within advanced
UMLworkshops [8] conducted in the industry.Dur- ing these workshops the participants were asked on several occasions to analyze simple design tasks. The participants worked on these tasks either individually or in small groups and their solutions were subse- quently discussed within the whole group. Our data includes the written solutions of the participants in theworkshops,documentationsof their groupdiscus- sions as observed and documented by the researchers, and transcripts of class discussions.The research pop- ulation included 41 software developers with experi- ence of 2–12 years in OO development. Because our objective was to describe a complex situation in its natural settings and its full complexity, we have used the qualitative research paradigm [12], which focuses
on case studies for obtaining specific insights rather than on large populations, simplified experiments, and statistical methods for discovering universal laws. (This is analogous to themethods usedby anthropol- ogists studying unfamiliar cultures.) During the research we documented, videotaped, and analyzed many relevant incidents and processes. The data analysis included coding the data obtained, and char- acterizing and classifying it to emerging categories. The full research findings and evidence will be described elsewhere. Here, we provide a selection of examples to demonstrate our findings. Confusing the direction of inheritance. A design task
concerning a hotel reservation system was presented for a discussion to a group of experienced engineers participating in a UML workshop. The instructor suggested using three classes (email, fax, and phone), to represent the three corresponding modes of enter- ing reservations. The possibility then arose of using
inheritance relations between concrete classes to exploit shared func- tionality and features, such as checking the availability of a room. For example, the class
faxcould inherit fromthe class email, since a fax object requires more handling (such as scanning and digitizing), hence has more functionality, than an email object.
Instructor: Under the restriction that for now we only use these three classes, can any of these classes inherit from another class? Can we use the fact that they have many things in common? [The participants hesitate]… Instructor: For example, fax is like email, only with a few more tests.
Dan: Email inherits from fax, because email is the same as fax, only with fewer tests.
Instructor: So, email has less functionality than… Dan [hastily]: Oh, right, it should be the other way around.
In view of this and similar observations, we pre- sented a group of 10 software developers with a sim- ilar question in order to check this phenomenon moredirectly.The answersweredivided5:5between the two possible directions of inheritance. Signifi- cantly, as in the bat-and-ball and in Dan’s case, the participants who chose the wrong direction required only a small nudge (with no informational or explanatory content) to quickly change their mind. Analysis: All the participants in the research have
COMMUNICATIONS OF THE ACM May 2008/Vol. 51, No. 5 43
Client
Name
Login Register
Server
ValidateUser InsertNewUser
A design of authorization system.
Hadar_ lo:Intro_ lo 4/28/08 3:05 PM Page 43
several years of experience in OO software develop- ment. Why do intelligent and experienced profes- sionals have difficulties with such an elementary issue? We propose that the same mechanism used by Kahneman to explain the bat-and-ball phenomenon is also inoperationhere.Specifically, S1with itsquick andeffortless operation“hijacks” the thinkingprocess andproduces a response that seems roughly appropri-
ate,while the slow and effortful S2 remains dormant. This analysis gets additional support from the obser- vation that the small cueofferedby the instructordid- n’t teach the participant anything new, only served to wake up S2; the necessary knowledge was there all along, but the dual system analysis is needed to explain why it was not mobilized.
W hy would S1 and S2 clash about the meaning of inheritance? In people’s everyday intuition (S1), inheritance is about trans- ferring “stuff” (such as property or money), and the direction is usually
from the person who has more to the one who has less. For example, in an informal poll we asked stu- dents, in the context of OOD, what is the relation between a doctor and a paramedic in an ambulance? A typical reaction was, “paramedic inherits from the doctor because the doctor has more qualifications.” Similarly, we predict that most people would say that a student “inherits” from the professor (because the professor has more knowledge) and not vice versa. But in the OOD formalism (S2), the reverse is true: the classwithmore functionally inherits fromtheone with less. Difficulties in identifying objects. One of the first
tasks inOODis“carvingagiven scenarioat its joints” in terms of objects and classes. In one of the work- shops the participantswere asked to design an autho- rization system that will route users as follows:
• An existing user will login into the system. • A new user will register and receive authorization.
A typical design would look like the accompanying
figure. The following discussion took place while the participants were working in pairs on the task.
Ron: Let’s define login and register as objects. Sharon: Do login and register seem like objects to you?
Ron: Why not? Sharon: An object is a client, for example.
Ron: Client is also an object. Login and register are activated and operate within the system; therefore they can be defined as objects.
Sharon: I’ve never seen an object login. Ron: Don’t worry, it will be okay. You’ll see how I design the system; it will be just fine.
Sharon [hesitates, at last reluctantly giving in]: Okay, fine, although it doesn’t sound good.
Analysis: Ron’s decision is a typical S1 behavior, simi- lar to thatobserved in thebat-and-ball task. In search- ing for objects he is influencedby the surface features of the task (the salience of the terms login and regis- ter in the task description) rather than its essential (though implicit) components. Unlike the bat-and- ball phenomenon,Ronrequiresmore thananudge to change his mind, which seems to imply that his S2 knowledge in this regard is not too firm either. Sharon, in contrast, seems tohave a firmer senseof
the right objects, but this too is S1 knowledge, in the sense that she cannot explainher choice.Her attempts at convincing Ron involve expressions like “I’ve never seen an object login,” and “it doesn’t sound good,” which show that she relies on her vast past experience (S1) rather than on analytical rule-based reasoning (S2). Sharon’s example, in contrast to the other exam- ples presented in this article, demonstrates how using intuitionmay in fact contribute positively, even in sit- uations of formal problem solving.
CONCRETIZING ABSTRACT CLASS Confusing characteristics of abstract and concrete classes. Abstract class is a class with at least one virtual func- tion. Thus one can’t instantiate concrete objects directly from an abstract class, but only through a (concrete) inheriting class. In this example, Rebecca chose to define an abstract class car and the following discussion ensued.
44 May 2008/Vol. 51, No. 5 COMMUNICATIONS OF THE ACM
Under the demands of abstraction, formalization, and executability, the formal OO paradigm has come to sometimes clash with the very institutions that produced it.
Hadar_ lo:Intro_ lo 4/28/08 3:05 PM Page 44
Rebecca: Let’s say car is an abstract class. Then, in one design I can inherit from it Chevrolet and Rolls-Royce, and in another design I will instanti- ate an object car with manufacturer value Chevrolet.
Instructor: Is car an abstract class? Rebecca: No, yes, that’s not the point...
In a subsequent interview with Rebecca, the researcher probed the matter further.
Researcher: Rebecca, what did you mean by the car example?
Rebecca: I just tried to show that there are two design possibilities using an abstract class, but I got mixed up.
Researcher: What was the problem? Rebecca: I wanted to show that you can instantiate objects with parameters instead of using inheri- tance tree… but it didn’t work out.
Researcher: Why? Rebecca: Because the moment I instantiate objects, I cannot define the class as abstract.
We note that this was not an isolated case. While it seems that the participants in this study recognize the distinction between abstract and concrete classes in theory, several cases were observed where they referred to abstract classes as if they had the charac- teristics of concrete classes. Even in some written solutions, we found cases where an abstract class was defined but was subsequently used as a concrete class. Analysis: Rebecca knows the difference between
concrete andabstract classes,but this isS2knowledge. Our interpretation of howS1worked in this example follows from the dual nature of the relationship between thenatural and the formal conceptual frame- work concerning categories and objects. On the one hand, OOD builds on the intuitions of the natural concepts, but on the other hand, the natural system sometimes clashes with the formal one. We propose that this is what happened in Rebecca’s case. Specifi- cally, in the natural categorization system [5], there is no parallel for the formal OOD concept of abstract class (a class from which no concrete objects can be instantiated). Hence, when Rebecca’s S2 was not on guard, her S1 took over and slipped from abstract to concrete class.Asbefore, a small nudgewas enough to wake up S2 and lead Rebecca to make the necessary distinction. Identifying software development with coding. Cod-
ing is an important softwaredevelopment activity, but other no less important activities contribute to soft-
ware development, such as requirements analysis, design, and testing. We observed participants under- weighting these other activities, to the extent of iden- tifying software development with coding.2 The following discussion occurred in an interview regard- ing time invested in different activities:
Ann: Most of the time I was occupied with devel- opment.
Researcher: What do you mean development? Ann: You know, writing the code. For me coding and developing are the same thing, even though I know this is not correct.
Analysis: Ann’s first automatic response, that devel- oping is the same as coding, is an S1 response. S1 consists of what is most accessible and what comes most easily tomind; here the viewofdevelopment as coding comes tomind, presumably because the code is the final and most tangible product of the whole process, while the other components (such as design and requirement analysis) are less conspicuous. The interviewer’s question served as a nudge that woke up S2, hence the utterance: “though I know it is not correct.” In fact, her second pronouncement is a good demonstration of an actual clash between the two systems: S1 expressing the view that “coding and developing are the same thing,” but simultaneously, S2 objecting that “I know it is not correct.”
HOW INTUITIVE IS OO DESIGN? So, how intuitive is OOD? Well, in a certain sense it indeed is intuitive: our cognitive system certainly makes extensive use of objects and categories, on which this paradigm is built. However, as often hap- pens in the evolution of formal systems, this rela- tionship has a flip side [9]. Under the demands of abstraction, formalization, and executability, the for- malOOparadigmhas come to sometimes clashwith the very intuitions that produced it. Thus, while objects, classes, and inheritance certainly have an intuitive flavor, their formal version in OOD is dif- ferent in importantways from their intuitive origins. Dual-process theory, imported fromcontemporary
cognitivepsychology,highlights theunderlyingmech- anism of those situations where our intuitions clash with our more disciplined knowledge and reasoning. Or, put in Kahneman’s words [4]: “Highly accessible features will influence decisions, while features of low accessibility will be largely ignored. Unfortunately, there is no reason to believe that the most accessible features are also themost relevant to a gooddecision.”
COMMUNICATIONS OF THE ACM May 2008/Vol. 51, No. 5 45
2This observation was obtained in a joint study with Peleg Yiftachel.
Hadar_ lo:Intro_ lo 4/28/08 3:05 PM Page 45
Indeed,wehave seen that, under the force of these general cognitive mechanisms, deciding on appropri- ate objects, classes, and relations is sometimes influ- enced by irrelevant surface clues or everyday meanings of these concepts, thus leading to inappro- priate choices. Intuition is a powerful tool, which helps us navigate successfully through most everyday tasks, butmay at times get in thewayofmore formal processes.Wehope this articlemay contribute tobet- ter understanding of this problem, andpoint theway to thinking about its resolution.
REFERENCES 1. Armstrong, D.J. The quarks of object-oriented development. Com- mun. ACM 49, 2 (Feb. 2006), 123–128.
2. Gilovich, T., Griffin, D., and Kahneman, D., Eds. Heuristics and Biases: The Psychology of Intuitive Judgment. Cambridge University Press, 2002.
3. Holmboe, C. A cognitive framework for knowledge in informatics: The case of object-orientation. ITiCSE’99 Conference Proceedings, (June 1999), 17–20.
4. Kahneman, D. (Nobel Prize Lecture). Maps of bounded rationality: A perspective on intuitive judgment and choice. In Les Prix Nobel, T. Frangsmyr, Ed. (2002), 416-499; www.nobel.se/economics/laureates/2002/kahnemann-lecture.pdf.
5. Lakoff, G. Women, Fire, and Dangerous Things. What Categories Reveal about the Mind. The University of Chicago, 1987.
6. Leron, U. and Hazzan, O. The rationality debate: Application of cog- nitive psychology to mathematics education. Educational Studies in Mathematics 62, 2 (2006), 105–126.
7. Morris, M.G., Speier, C., and Hoffer, J.A. An examination of proce-
dural and object-oriented systems analysis methods: Does prior experi- ence help or hinder performance? Decision Sciences 30, 1 (Winter 1999), 107–136.
8. OMG Object Management Group. UML Notation Guide. Version 1.3, 1999.
9. Paz, T. and Leron, U. The slippery road from actions on objects to functions and variables. Journal of Research in Mathematics Education; http://edu.technion.ac.il/Faculty/uril/papers/Paz_Leron_Actions_vs_ Functions.pdf.
10. Stanovich, K.E. and West, R.F. Individual differences in reasoning: Implications for the rationality Debate. Behavioural and Brain Sciences 23 (2000), 645–726.
11. Stanovich,K.E. andWest,R.F.Evolutionary versus instrumental goals: How evolutionary psychology misconceives human rationality. Psy- chology Press, 2003, 171–230.
12. Strauss, A. andCorbin, J. Basics of Qualitative Research: Grounded The- ory Procedures and Techniques. Sage, Newbury Park, 1990.
Irit Hadar ([email protected]) is a lecturer at the Department of MIS, University of Haifa, Israel. Uri Leron ([email protected]) is a Churchill Family Professor (Emeritus) of Science and Technology Education at the Technion— Israel Institute of Technology, Haifa, Israel.
Permission to make digital or hard copies of all or part of this work for personal or class- room use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee.
© 2008 ACM 0001-0782/08/0500 $5.00
DOI: 10.1145/1342327.1342336
c
46 May 2008/Vol. 51, No. 5 COMMUNICATIONS OF THE ACM
Hadar_ lo:Intro_ lo 4/28/08 3:05 PM Page 46