A Laboratory for Teaching Object-Oriented Thinking

A Laboratory for Teaching Object-Oriented Thinking

A Laboratory For Teaching Object-Oriented Thinking Kent Beck, Apple Computer, Inc. Ward Cunningham, Wyatt Software Services, Inc. It is difficult to introduce both novice and reduces to teaching the design of objects. We experienced procedural programmers to the focus on design whether we are teaching basic anthropomorphic perspective necessary for concepts to novices or the subtleties of a object-oriented design. We introduce CRC complicated design to experienced object cards, which characterize objects by class name, programmers. responsibilities, and collaborators, as a way of giving learners a direct experience of objects. Rather than try to make object design as much We have found this approach successful in like procedural design as possible, we have found teaching novice programmers the concepts of that the most effective way of teaching the objects, and in introducing experienced idiomatic way of thinking with objects is to programmers to complicated existing designs. immerse the learner in the “object-ness” of the material. To do this we must remove as much familiar material as possible, expecting that 1. Problem details such as syntax and programming environment operation will be picked up quickly The most difficult problem in teaching object- enough once the fundamentals have been oriented programming is getting the learner to thoroughly understood. give up the global knowledge of control that is possible with procedural programs, and rely on It is in this context that we will describe our the local knowledge of objects to accomplish perspective on object design, its concrete their tasks. Novice designs are littered with manifestation, CRC (for Class, Responsibility, regressions to global thinking: gratuitous global and Collaboration) cards, and our experience variables, unnecessary pointers, and using these cards to teach both the fundamentals inappropriate reliance on the implementation of and subtleties of thinking with objects. other objects. Because learning about objects requires such a 2. Perspective shift in overall approach, teaching objects Procedural designs can be characterized at an Permission to copy without fee all or part of this material is granted provided that the copies are not made or distributed for direct commercial advantage, abstract level as having processes, data flows, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for and data storestlr, regardless of implementation Computing Machinery. To copy otherwise, or to republish, requires a fee language or operating environment. We wished and/or specific permission. 0 1989 ACM 089791-333-7/89/0010/ooO1 $1.50 to come up with a similar set of fundamental October 1-6, 1989 OOPSLA‘89 Proceedings 1 principles for object designs. We settled on three because the concreteness of our method dimensions which identify the role of an object in substitutes for naming of instances. This also a design: class name, responsibilities, and makes our method for teaching independent of collaborators. whether a class or prototype-based language is used. The class name of an object creates a vocabulary for discussing a design. Indeed, many people have remarked that object design has more in 3. CRC Cards common with language design than with procedural program design. We urge learners The second author invented CRC cards in (and spend considerable time ourselves while response to a need to document collaborative designing) to find just the right set of words to design decisions. The cards started as a describe our objects, a set that is internally HyperCard r31stack which provided automatic consistent and evocative in the context of the indexing to collaborators, but were moved to larger design environment. their current form to address problems of portability and system independence. Responsibilities identify problems to be solved. The solutions will exist in many versions and Like our earlier work in documenting the refinements. A responsibility serves as a handle collaboration of objects 141,CRC cards explicitly for discussing potential solutions. The represent multiple objects simultaneously. responsibilities of an object are expressed by a However, rather than simply tracing the details of handful of short verb phrases, each containing an a collaboration in the form of message sending, active verb. The more that can be expressed by CRC cards place the designer’s focus on the these phrases, the more powerful and concise the motivation for collaboration by representing design. Again, searching for just the right words (potentially) many messages as a phrase of is a valuable use of time while designing. English text. One of the distinguishing features of object As we currently use them, all the information for design is that no object is an island. All objects an object is written on a 4” x 6” index card. stand in relationship to others, on whom they rely These have the advantages that they are cheap, for services and control. The last dimension we portable, readily available, and familiar. Figure 1 use in characterizing object designs is the shows an idealized card. The class name appears collaborators of an object. We name as underlined in the upper-left hand corner, a bullet- collaborators objects which will send or be sent messages in the course of satisfying responsibilities. Collaboration is not necessarily ClassName Collaborators a symmetric relation. For example in Smalltalk- .. 80[*1,View and Controller operate as near equals Responsibilities (see example below) while Orderedcollection . offers a service with little regard or even awarenessof its client. Throughout this paper we deliberately blur the distinction between classes and instances. This Figure 1. A Class-Responsibility-Collaborator(CRC) index card. informality is not as confusing as it might seem 2 OOPSLA‘89 Proceedings October 1-6, 1989 View Controller Design with the cards tends to progress from Render the Model. Model l- I I knowns to unknowns, as opposed to top-down or Transform coordi- nates. Controller bottom up. We have observed two teams arriving view Interpret user input. Model at essentially the same design through nearly Distribute control. opposite sequences, one starting with device drivers, the other with high-level models. The problem demanded a certain set of capabilities which both teams discovered in the course of fulfilling the requirements of the design. Mode/ Maintain problem related info. We suggest driving a design toward completion Broadcast change with the aid of execution scenarios. We start notification. with only one or two obvious cards and start playing “what-if”. If the situation calls for a responsibility not already covered by one of the Figure 2. CRC-cards describing the responsibilitiesand objects we either add the responsibility to one of collaborationsof Smalltalk’sModel, View andController. the objects, or create a new object to address that list of responsibilities appears under it in the left responsibility. If one of the object becomes too two-thirds of the card, and the list of cluttered during this process we copy the collaborators appears in the right third. information on its card to a new card, searching for more concise and powerful ways of saying Figure 2 shows an example taken from the what the object does. If it is not possible to Smalltalk- image, the much-misunderstood shrink the information further, but the object is model-view-controller user interface framework. still too complex, we create a new object to We have deliberately shown only a portion of the assume some of the responsibilities. responsibilities each of these objects assumes for clarity of exposition. Note that the cards are We encourage learners to pick up the card whose placed such that View and Controller are role they are assuming while “executing” a overlapping (implying close collaboration) and scenario. It is not unusual to see a designer with placed above Model (implying supervision.) We a card in each hand, waving them about, making find these and other informal groupings aid in a strong identification with the objects while comprehending a design. Parts, for example, are describing their collaboration. often arranged below the whole. Likewise, refinements of an abstraction can be collected We stress the importance of creating objects not and handled as a single pile of cards with the to meet mythical future needs, but only under the most abstract card on top where it can represent demands of the moment. This ensures that a the rest. design contains only as much information as the designer has directly experienced, and avoids The ability to quickly organize and spatially premature complexity. Working in teams helps address index cards proves most valuable when a here because a concerned designer can influence design is incomplete or poorly understood. We team members by suggesting scenarios aimed have watched designers repeatedly refer to a card specifically at suspected weaknesses or they intended to write by pointing to where they omissions. will put it when completed. 3 October l-6, 1989 OOPSLA ‘89 Proceedings 4. Experience team that produced the cards was quite happy with the design, the recipient was unable to make One of the contexts in which we have used CRC senseof the cards out of context. cards is a three-hour class entitled “Thinking with Objects,” which is intended for computing Another experiment illustrates the importance of professionals who have programmed, but whose the context established by the handling and jobs do not necessarily involve programming discussing of cards. We had videotaped every day. The class proceeds by introducing a experienced designers working out a problem data flow example (a school, with processes for similar to the bank machine. Our camera teaching and administration) which is then recast placement made cards and the designers’ hands in terms of objects with responsibilities and visible but not the writing on the cards. Viewers collaborators (such as Teacher, Janitor, and of the tape had no trouble following the Principal).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us