The International Newsletter for Programmers

July/August 1992 Volume I Number 9

malltalk programmers routinely read more code than they write. One of the IMPLEMENTING more difficult things in mastering Smalltalk is mastering the underlying class libraries. The act of programming consists of “hunting” for the appro- priate protocols in the appropriate classes. The hallmark of a good PEER CODE SmalltalkerElis the ability to efficiently navigate the increasingly vast landscape of the class libraries. It is very likely that a well-written class will be read many times over. Typicidly, these classes serve as role models for people who aspire to be good Smalltalkers. In the REVEVVSIN same vein, badly written classes that have to be used all the time serve as poor role mcxlels and tend to propagate poor programming practices. Code reviews are a critical software engineering activity. Research studies have shown SMALLTALK that code inspection alone can catch 75–%)% of the errors. Code reviews serve as a cri- tique of a software component by someone other than the author of the component. Typi- cally, reviewers are peers in the same organization who may or may not be on the deveh]P- ment team. Different organizations employ different practices for implementing code reviews. In traditional software organizations, rhe author prints out a listing of the modules m be reviewed and circulates it to the review team. The reviewers mark it up using guide- By S. Sridhar lines. They meet with the author in a face-to-face meeting a few days later where they pre- sent and discuss the review comments page by page, The author is then left with the Contents: daunting task of collating and integrating the comments of all the reviewers. h is quite possible that more than one person has caught the same programming infraction; that Features/Articles means multiple reviewers have spem time documenting the same problem and possibly I Implementing Peer Code suggesting the same fixes. This is an unnecessary duplication of effort, Reviews in Smalltalk This article describes a code review process that is specifically geared to reviewing small by S. Sridhar or large chunks of Smalltalk code. I’ll discuss extensive guidelines for effective code cri- 3 Quality assurance issues for tique and review, and describe a rigorous process that we have adopted in our organization Smalltalk-based applications to execute a comprehensive review, by Ed Klimas Columns THE PROCESS I 4 The13estof Chp.Lang.Srna/hallc My work group, like most Smalltalk work groups, uses a team software engineering tool to What’s wrong with 00P? manage the software development process. The tool we use is the ENVY/Developer envi- by A/an Knight ronment (hereinafter referred to as ENVY). This tool provides the facilities required for 18 Smalltalk Idioms Abstract the development and maintenance of large software systems. It provides sophisticated ver- control idioms sioning, configuration and release management capabilities as well as mechanisms for co- by Kent Oeck ordinating and integrating the software development activities of multiple developers. All 2 I Getting Real:Creating subclasses of the program development information including source code, compiled methods, mod- byjuanita Ew”ng ule dependency gtaphs, component ownership, versioning and configuration details are Departments stored in a shared repository. This repository is accessible to all members of the techniral 24 LabReportSmalltalk research at team. We use ENVY as a practical tool to aid in our code review process. It would be feasi- the University of Florida ble to adapt this approach to code reviews in the context of other team development envi- by@tin O. Graver ronments as well. 25 ProductAnnouncemenfi At the outset of a project, we typically partition the tasks among the developers along 26 Highlights functional lines. For example, one developer may be working on specific domain abstrac- cuminudm NC 8 EDITORS’ me SnlamamRepofi Editon CORNER J.hnPughand hd Whiu5 Cuban Lhlverdq& ThQOb@t W@.

John Pugh Paul white SIGS Punuamoiw ~- euse is the name of the game. Headlines shout. Marketing literature trumpets. Salesmen Torn Anvood, ObIacrDaaiso ooze. Objects will solve your reuse problems. Not true, of course. Programmers solve Grady M, sadond reuse problems.” So says Kent Beck in the prelude to his Smalltalk Idioms column in this George Boawoti, oigkdk mad co%1~ Aga Comuidng issue. Kent knows, as do most experienced Smalltalk programmers, only too well that chuckDuff,Syn’Unw 1reuse does not come for free and is far from easy to attain. Developing truly reusable Adele Gold- l?idace Systetm components adds an extra dimension to the design and programming process, and addi- Tom bvq o@vwa, InC tional time and skill is required. BarcmndMeyer, ISE Mallir %gt+~ W@aod _ What if we had access to a quality set of reusable components for objects for some ap- Shesl PrW+, Cc~ne SOftmra plication domain? Would it now be easy to “assemble” new applications from these com- P. Mkhael Sesshols, Vamam ponents? Unless a great deal of thought has gone into the design and implementation of El@me-avup, AThT Ball @ the components (probably not), we will still need a Smalltalk guru to wire the pieces to- Dave Thamas, x Tech- karnadotul gether. Here is a sample list of questions for which we would need affirmative answers. ~ SMAUTALK ~ Do we have the right components? Do the components have the required functionality? Editorial Board Have they been fully tested? Do we have prefabricated components that model common J. Andarwn, _ processes within the domain, or do we simply have a collection of low-level building Adala GoHbew hrwaea sprain, blocks? Have the components been designed with standard interfaces? Have they been need Phlni-pa,KnOwrer&spwntrCorp. designed to work together? Mike Taylor, OI@I hW~Talw+ykmmdand Clearly, a number of things have to be in place before we can use a software-by- assembly approach to application development. However, there are low of analogous Columnists real-world examples where the benefits of this approach can be clearly seen such as the JuanItsEwlrig,OIglnlk Greg tlendiey, KnOwi+ SystUmcarp assembly of personal computers or the manufacture of automobiles. EdKHnlas,LlnaaEr@mari~Inc It’s this software-by-assembly approach to application development that Parts (formerly SmarmeSkubHc&oqecr Tachmlq lnd. LAFKit-Look and Feel Kit), a product currently under development at Digitalk, is at- Eric Smii, hwiedga SFWJUcorp. tempting to address. In his keynote address at Object Expo in New York City, Digimlk CEO RebeccavvHa-ElrOck Olghanl Jim Anderson teased the audience with a preview of the notions of software construction SiGS Publhtions Group, lraG from parts. Watch for more information on Parts in future issues of The Sma!hdk Report, RichardP. Friedman This issue features two significant contributions from recognized members of the Fwndar& GmuPFWlsher Smalltalk community that deal with the delivery of quality software. First, S. Sridhar re- A#Productlon turns to The Snudhzd.kRe@rt with a description of a mechanism for carrying out peer KrisdnaJwkhadar, MamgiIIsE&or code reviews on Smallralk projects. As is the case with all software development, PilgrimRd. Lzd. CreatheDIracdon Karen Te+rgiah,WOdwdOnE&Or whether done using Smalltalk or any other language and environment, code reviews are JennifarEngbndw, ~. -hamr a vital to ensuring the quality of deliverables. As Sridhar points out, “code reviews Ciawhtion should be viewed as a rigorous software enginering activity.” His discussion focuses on Km Mercadq ~- two aspects of code reviews, namely the process by which they should be carried out and oiana Bs&vay,ctwhdmlaudn8ssr-lma@r a set of guidelines to be followed by reviewers, Second, Ed Klimas’ article discusses many VW Mo* CbUdmwlAsskRna JohnSehreibaf, ClrcuhrhnAsbmnt issues that make testing Smalltalk systems unique and puts forward a number of guide- M~n~AdvewWng lines and strategies for planning for and documenting the development of test suites. Diana MOrMde, Aawm EuaCLKw Also in this issue, Juanita Ewing addresses many of the problems involved in carrying HollyMeii, kam Ex6adva out proper subclassing within Smalltalk applications. Always a confusing issue for people Gerakheschafm, kdrraaxszks new to Smalltalk, she describes the differing goals subclassing is used to satisfy and pro- SamhHamsron,Pnsnmbm-r Carwl Pmhler.RwmdarBGr@eti poses hueristics for making decisions concerning subclassing decisions. Alan Knight Adminlatmtion brings us up to date on a thread of discussion on USENET dealing with the hype sur- David Chterp4, timw rounding object technology. And finally, Justin Graver describes the activities of the cbh’eJOha@Ul,caOi%maf%rU& Smalltalk research group at the University of Florida. Cindy ROppeJ.Cahwr.a Cadlnamr Amysv PlqSSlal’4aqar JwllfarFkher,PUblkMatlOnS Helen NevriIng,wkninkmmwhkrmt

Narghelim n Melnck GananlMwm@r ❑ SIGS The ShndhslkRqnm (15SN* 1056-7976) is published9 rimes. rem, cvmymonth cxcepIfor the Mar/Apr, J.ly/Aus, and NmdDec cmnbinedissues. PUBLICATICSNS Publishmiby SIGS PublicmionsOIUIp, 588 BrmchvHy,New YndI, NY IKI12 (212)274-0640 Q @right 1992by SIGS Publications,II-C All righs rewved. &Iim of this materialbyelemrcmictrmmnisicm,Xerox or my othermethcdwill k tremrd us. wdlhl .ml.riom 04rhe LX Copyrght PJblmnm Orfuwmd Ofotjtd-orkmd FnQnm LEWand isSEdypmhibirml.M.rcrid IMY k reprducd with expres Ferrnissionhorn the phlishers. M.iled FirsI Clam.%b=riwion rumsI ye.., (!J mhE~M~Htdham~ iwm) .dmneSiq$65, Fmcign md Gnmch, $$+3,%@ cqy price, $8.00. POSTMASTER: Sad w2dre. +w.ges .nd ,.b=riptio. mdem t,. THE redmda#,lb?c++~rhcsnaia7ksqk@ SMAUTALKREMRT, Subsmik Srrvim, !&p[.SML, PO, Sm. K@ Lknvillc, NJ 07S34. Submit mticl= to the Editorsa! 91 SecondAvw..,, 7’balnmmMWd00PWeUcq, and17m X@wnd Otmwa,Onti KIS 1H4,Ciinak

THE SMALLTALK REPORT QUALITY Code development phase _ Unit testing ASSURANCE ● Integration testing . Validation testing

The benefits of pre-implementation code reviews and in- ISSUES FOR spections should not be underestimated. In terms of impacting overall finished product quality, inspections and design re- views are much less costly than computer-based regression SMALLTALK-BASED testing to isolate the same errors. Many existing review and inspection techniques are quite appropriate to the preimple- mentation phase of the O-O software quality assurance life cy- APPLICATIONS cle. Still, one significant contribution to a commercial prod- uct’s final quality is the testability of the code. The object-oriented development paradigm differs from Ed Klirnas conventional structured development in several ways, and so one should not assume that all O-O testing is necessarily the It is absurd to dividesoftwate into goodand bad. same. Testing commercial OQP/Smalltalk-based applications Software is either charming or tedious. still follows the software quality life cycle model. Likewise, —loosely basedupm Oscar Wilde %nalltalk does not pose any greater burden than conventional languages in this regard and may in fact offer some advantages malltalk-based object-oriented programming has under some circumstances, For example, procedural languages several technical advantages for improved pro- such as Fortran usually require several functions to be imple- ❑ grammer productivity and code quality over other mented before testing can begin. Smalltalk programs permit programming environments. These include: classes to be used and tested as soon as they are designed and the initial underlying methods are defined. This permits mean- ● Reuse of existing pretested robust libraries ingful testing to occur earlier in the development cycle and of- . Inherent encapsulation against “runaway code” fers the cost saving opportunity to diagnose and correct prob- lems earlier. Therefore, it is important to design Smalltalk ● The absence of error prone pointer manipulations programs for easy testability of the code from the start. ● Automatic memory management capabilities REGRESSION TESTING These inherent technical features do not, however, auto- Unit and integration testing are intended to uncover latent matically result in higher quality software. It is necessary to software errors, while validation test ing demonstrates trace- take explicit steps to design in quality from the start. One of ability to the requirements. Each of these steps typically re- the most important of these steps is testing. lies upon some sort of regression testing. Regression testing is This article will cover a number of issues associated with an important part of testing the impact of changes on the to- commercial Smalkalk application testing and propose a stan- tal body of code. Just as Smalltalk is encapsulated in an envi- dardized, yet flexible, platform independent protocol so class ronment for development, commercial developers should libraries and frameworks from multiple sources can be easily wrap their products into an environment that will easily suP- integrated and tested. port full testability of their work, If a few simple testing Testing is only part of the quality assurance process. Software guidelines are followed from system conception, significant quality assmrnce begins with design and code reviews and pro- time can be saved later during the subsequent refinements of gresses through a life cycle that is standard irrespective of the the system. programming tools. Whether a waterfall or iterative develop Commercial software requires the development of ancillary ment model is employed, the purpose of each step in the soft- test code to verify the proper initial functioning of the soft- wate quality life cycle can be summarized by the following stages: ware, and to verifi that the properly working functions of the software system are not inadvertently altered during subse- Pre-implementation phase quent code additions or modifications. Unfortunately, in ● Preliminary design reviews many organizations, the test suites are usually developed after the software is well underway and often by groups that are not . Detailed design reviews necessarily part of the original software design team, This does ● Code reviews, inspections and walk throughs not take advantage of the specific knowledge the original pro- 3. VOL. 1, No. 9: JJLYIAUGUST1992 ■ QUALITY ASSURANCE

duction code developer may have had of the system’s intended the production code and possibly even prototype code. A test functionality. Another shortcoming of many test smategies is plan should be composed of at least two basic components*: not testing for defects as soon as possible. The longer in the ● a brief description of the scope, applicable documents, test development cycle a defect has to go to be detected, the strategy higher the cost of fixing that defect. wthe actual test procedures, their purposes, test data, and ex- STRATEGIESAND GUIDELINES FOR MAKINGCODE TESTABLE pected results Testing is an extremely challenging task requiring software de- sign skills significantly exceeding those of ordinary developers. 1 Guideline: Create a test plan that covers every method in a Testing strategies change for different aspects of the develop- class and every path within a method. ment process. For example, an issue rarely addressed during Rationale: Complete coverage is the objective of the test rapid prototyping is testing strategies and the amount of effort process, In conventional programming languages, wirh required to develop meaningful test suites. To reduce the effort many lines of code in a module or subroutine, this task can associated with producing test suites and as a means for im - be quite daunting. Fortunately, good 00P style promotes proving the quality of the test suites, software should be de- the idea that methods should be short, typically less than signed with testing in mind from the start. Most Smalltalk de- ten lines of code. This significantly reduces the complexity velopment involves the creation of “test harnesses” to exercise of possible paths to be tested within a given method. An- code during development, Following a few simple guidelines other benefit of short methods is that it is much easier to can help to evolve the normally throw-away test harnesses into look for bugs in small pieces of code rather than in large valuable permanent tools for improving overall product qual- program segments. ity. The following is a synopsis of test strategies and guidelines Guideline: Test cases should be written to uncover general to be followed during the various phases of Smalltalk-based classes of problems rather than one discrete error, product development. Guideline: Results of testing should typically be logged to a Guideline: In object-oriented programming, the class is a nat- file in a standard format that contains a record of the success- ural unit of unit testability. Test suites should be based on ver- ful/unsuccessful test of classes and methods that have been ifying the proper functionality of each method (both instance performed. and class methods) associated in with a class. Guideline: If the system permits, the status of the tests should Guideline: In object-oriented programming, the application also be displayed directly on the screen using standardized for- or project is the natural unit of integration testability. The in- mats. If direct writing on the screen is not possible, then a file tegration tests should focus on testing the proper functionality should be used. of collections of classes, Rationale: Displaying status to a window during testing is typ- Rationale: Integration testing is important because many ically problematic as it may cause unwanted cycling of win- sources of bugs can be between pieces of code where one dows, that can complicate testing. mekod makes assumptions that another doesn’t fulfill. Guideline: Print general messages (i.e., Testing class XYZ) di- Guideline: Take advantage of the higher productivity of ob- rectly on the screen not in windows. ject-oriented development environment, and push more of Ratiomle: The transcript window shouldn’t be cluttered with the unit and integration testing up frrrnt into the developers’ routine and unnecessary status information. If the application domain as soon as possible. has created a bug in the windows there is a possibility that the Rationale: This approach will permit the developer, who has test routines themselves may be affected. detailed knowledge of the expected functionality, to develop Guideline: Display ertors and log messages along with the test strategies more effectively and to begin using them in date and time in the transcript window. conjunction with the code development. Rationale: The transcript window provides a window that al- Guideline: Validation testing should be performed by an in- ways exists to record error log messages for later retrieval. dependent testing group in conjunction with the code devel- Guideline: Application windows should beat least momen- opers ), to verify the conformance of the software to the re- tarily displayed for testing. quirements specifications. The validation testing should not Rationale: Testing windows in a specific environment can be only verify proper functionality, but acceptable timing perfor- performed using various third party packages to record mance also. keystrokes and mouse movements and then play the sequence Rationale: This approach permits a fresh opportunity to un- back testing for the appropriate response or display in a win- cover quality problems the original developer may have to- tally overlooked as well as an independent, and unbiased veri- * The overall high level plan, scope and test strategy are most conve- fication of the actual quality level of the system, niently documented using a code management system to associate Guideline: Each developer should prepare a formal unit and in- them with an application or projecr, while the actual test procedures tegration test strategy plan and appropriate test suites for all of can be associated wirh the related classes. 4. THESMALLTALKREPORT The original and still premier AM/STm application munager for SmalltalklYTM

AM /ST, developedby the SoftPert ChangeBrowser. As an additional Sys~ms Division of Coopers & tool availablefor SmalMk/V PM Lybrand, enables the developerto andSmalltalk/V Windows, Change- managelarge, complex, object-orient- Browset supportsbrowsing of the ed applications.The AM/STAppli- Smalltalk/V change log file or any cation Browser providesmultiple file in SmaUtalk/Vchunk format. views of a developer’sapplication. The additionof AM/STto the AM/STdefines Smalhalk/V applica- ImageSoft Family of softwaredevelop- tions as logical groupingsof classes and ,, ment tools enhances and solidifies metbods which can be managedin source ,;, ItnageSolt’s position as — files independentof the Smrdltalk/V “The World’s Leading publisher ‘ image. An applicationcan be locked and of Object-Oriented Software l!!!!‘ modifiedby one developer,enabling other DevelopmentTools.” developersto browse the source code. The source code control system managesmulti- plerevisions easily. ~~ 1-800/245-8840- ‘+*$ @j#$@j# .;,:,. .-, mFtff : ‘::~i-.wwe’+? ;~:,“,’,: lmageScl.lkwtd6’sb6iq Flblisberti~elopncm Tm4s

.431n-ahmk m he pmply of tkii respive owners, lmwSoft, inc., 2 Haven Avenwe, Port Wasb@mI, NY 11050 5 16/767-2233; F.IX 5 16/767-9067; UUCP address: mcdhup!image!info

dow segment. Unfortunately, this strategy cannot be easily for testing a system’s ability to properly function even when implemented when testing the application for multiple plat- there are significant interrupts to the normal processing flow. forms. If the application is to be executed on multiple plat- Rationale: Stress testing is one strategy that is intended to fotrns, a pragmatic strategy for testing the windows is to dis- capture subtle bugs such as memory leaks or deadlock condi- play all of the windows in sequence. Although this may not be tions that may not be evident under o[her types of testing. as rigorous as some commercial quality testing criteria, the ap- Stress testing should include testing over a wide range of volu- proach usually has a very high probability of identifying prob- minous inputs for a long period of time. lems that were caused by inadvertent changes to the code Guideline: Testing strategies should include timing as an im- somewhere in the system. portant characteristic in determining if functionally correct, Guideline: A library of standard routines should be evolved to but nonetheless detrimental, changes have been inadvertently assist developers in more easily testing their code functional. introduced into the system. ity. Candidate functions for this libra~ can include routines Guideline: Do not assume that only the changed class and its to force standard keyboard inputs, mouse movements, and subclasses need to be retested. All superclasses as well as sub- possibly even to compare screen displays against previously classes of a new class need to be retested whenever a change is stored and tested pixel displays. Interactive applications made to a class.2 should test themselves (i.e., Dispatchers test models). Some Rationale: One might argue that, theoretically, no testing of dialects of Smalltalk support an event or an eventxvith:message superclasses is required if the changes to the class do not ac- that can be used to easily simulate mouse and keyboard func- cess any superclass variables or superclass methods. However, tions for regression testing purposes. it is impossible to automatically guarantee that such an inter- Guideline: During incremental development, unit and inte- action can not occur. Object-oriented programs must test all gration test suites should be simultaneously developed and of the methods in a hierarchy both above and below the cur- exercised, rent class position in the hierarchy (subclasses inherit all of Rationale: Problems with the code will most likely occur with the changes in their superclasses, while superclasses can have the new functionality added to the system. The developer can their apparent functionality ovettidden by subclasses). There efficiently focus debugging efforts on the small subset of new are a number of examples one can conceive where subclasses code rather than a labor intensive debugging of a much larger, can change data in their superclasses via global variables or by more complicated piece of code. accesses of superclass instance variables. This situation is fur- Guideline: Testing strategies need to incorporate mechanisms ther complicated by the possibility that a subclass might inad- 5.

VOL. 1, No. 9: JULYIAUGUST1992 ■ QUALITY ASSURANCE

vertently call superclass methods in an incorrect sequence and Rationale: Overriding methods can have significantly differ- thereby create an invalid state for other potential classes that ent functionality than their superclasses and they need to be need to interact with the superclass. For example, consider a tested accordingly. For example, a class may have a method to subclass that erroneously instructs a superclass to clear a dis- update a display window and there maybe an optimized sub- play window rather than put up a grid whenever a display class that has the same overriding method to only update the command is received. Other subsequent operations might be corrupted part of a display window. Both of these cases need expecting a grid to already be on the screen. Hence, there is separate test strategies to confirm proper functionality. no silver bullet in avoiding complete regression testing of class Guideline: Every class should have a class method called self- hierarchies whenever a change is made. Test that will execute all of the class and instance methods and Guideline: Do not assume that a superclass test method is ad- return a Boolean true if all of the test cases pass or else return a equate for testing a method that overrides it in a subclass.2 Ev- Boolean fahe if any test fails. ery method in a class needs to be tested even if it overtides su- Ratiomle: The test routines should have standard protocols perclass methods that are tested in the superclass. to leverage off the object-oriented polymorphism and inheri-

Object EXAMFLE i: I aubclas: #RegTest ● inslaztceVsriabb41ames:“ **.******************* ************”* I elaasVariableNames:” Prt@et : RqresrdMest poolDictionaries:“! Date : May.26,1992 Time : 12:01:25 RegTestsubclass: #NotOkTest instancehiablel!ames:” Introduction .— rlas.sVaiableNames:“ I poolDicbosraries:”! Regressiontesting tiamework RegTestsubclass: #OkTest parbaUycompleteexample. instanceVariableNames:“ Thisapplicationwillpermita userto classVariableNames:“ kclude a classmethod calledaelfTest poolDiciionaries:”! in each class to test the various !NotOkTestclass methods ! instance and cfaasmethods t%rproper selfkst functiomli~. If the tests pass, selPkst “Public-” is expectedto retusn a Booleantrue, othtie ‘false! ! a Booleanfalse. !RegTestclass methods ! Thetetig is Misted with se~eat ObjecttesMU. ‘public-” Theresult ofthis testis a coUerlion %ue! ! of all of the faiied classes. !Objectclassmethods ! Dependenaes: none testAU I “Public-Pindall of the classeswhich implementthe class Invoked By method selffest and exerute the method for those classes --—————.—— ———- I returning an ordered coUectionof all ofthe failed classes. To Objecttestall I test, execute Description ObjecttestAU .==-==- ~ with a showit.” Puuyowned classes● : I aUObjectSubclassestes’flasses okClassesfailedClasses] Object testtlasses := OrderedCoUeciionnew. 30. .RegTest● okClasses:= OrderedCollectionnew: 30. ..NotOkTest● tikdClasses := OrderedCoUefionnew 30. ..OkTeat* self withAUSubclasses Methodsof Par&Uy Owned-: # do: [:eachClassI #testAUde6ned in Objectclass, (eachClassclassincludesSelector:#selfTest) ●****************************”*****●*”, iflkue: [testClassesadd: eachClass]]. te~Classes SmaUtaUrak #Objert ifAbsenk [ do: ~each I Nl subclass: #Object each selffest instancaVariableNames: “ ifhre: [okClassesadd: each] classVariableNsrnes ifPalse:[failedClassesadd: each]]. ‘RecuraionInErrorDependentsRecuniveSet’ ‘failedClasses! ! poolDictiontiex”] ! 6. THESMALLTALKREPOIST tance that promote increased productivity and reusability. It abandoning common-sense practices in their code develop- is important that this protocol is followed as a standard so ment and design review practices. that testing can be automatically accomplished even when Guideline: Budget at least one-third of the total development applications, projects, or frameworks from different develop- effort for testing. ers are combined into larger systems. By following this guide- Rationale: Irrespective of whether O-O or conventional line’s standard protocol, any or all of the code in the system languages are used, test code is a significant percentage of can be regression tested for any unexpected side effects using the total product effort and in some cases can contain more a simple method such as code than the actual run time functionality. 3 The test suites are typically of the same magnitude of source lines of code Objecttetill. as the product development effort. On the basis of conven- where the method selflest would be included in each class to tional practices, this activity can be expected to account be tested (see Example 1). for at least one third of the programmers’ total effort. Fur- Guideline: Every class should have an example or set of ex- thermore, testing of mission critical applications where hu- amples showing its use as shown in Example 1. man life is at risk can consume over 80% of the total devel- Guideline: Every example should have an executable test case opment effort. in a comment as shown in Example 1. CONCLUSION AN ERROR CHECKLIST Smalltalk offers significant potential for overcoming many A number of common errors can be the basis for testing rou- reliability shortcomings of other programming systems, but tines.l These tests ** can include checks for: extensive reuse of Smalltalk-based libraries requires some consistent standardized protocols and testing approaches. 1. Input and output validity Unfortunately, software testing and quality assurance issues 2. Missing inputs are often unnecessarily overlooked in the normal rapid pro- totyping developments that are so well suited to Smalhalk. 3. Range violations This article has highlighted testing guidelines and proposed 4. Proper handling of incorrect inputs an initial standard framework for testing of reusable code modules. The guidelines, if followed from the initial phases 5. Unwanted interactions with other methods and classes of development, can result in more robust, testable, and via global or class variables or pool dictionaries hence reusable frameworks with a minimum of additional 6. Integrity of data structures (e.g., do persistent objects effort. ❑ match the current classes’ instance variables?)

7. Proper error handling (e.g., can a recursive error cause ACKNOWLEDGMENTS the system to abort?) The insightfulreviewsof thk documentbyProfessor RaIphlohn- 8. Ncsnexecutable code son, University of Illinois at Urbana and Ms. Kate Funkner of the AL!en-BradleySoftware Qtudity Assurance GroufI are gratefully 9. Infinite loops acknowledged. 10. Testing at the limits of data structures or around mini- mum and maximum values FiEFEllENCES

1. Myers, G. THEART OF SOWWARE TESTING, Wiley InterScience, CAVEATS New York, 1979. Guideline: Immediately seek help if an impasse is reached 2. Perry, D.E. , and G.E. Kaiser. Adequate testing and object-ori- during testing and debugging. ented programming. JOURNALOFOBJECT-OFUENTEDPROG~AM- Rationale: Days and even weeks of effort can be wasted on glar- MING,January/February, 1990. ing errors invisible to one person but readily apparent to another. Guideline: Don’t get too caught up with regression testing 3. Rettig, M. Testing made palatable, aMMUNICATIONS OF THE of code! ACM, 34(5): 25-29,1991. Rationale: The downside of depending too much upon regres- sion testing of code for quality assurance is that the developers can place disproportionate effort in regression testing while Ed Klirrras is Managing Director of Linea Engineering Inc.r a supplier of custom object-miented based solutions for automation and indus- m“a[applications. Ed, along with Dave Thomas and Suzanne Skublics ** since unexpected inputs are a major source of software failures, the of Object Technology Intes-ruatiorrai,are coauthors of an upcoming importance of these tests can not be overemphasized. Addison-Wesleybook tided SMALLTALKWITHSTYLEtkt covers

VOL. 1, AJo. 9: JULYIAUGUST1992 H PEEFt CODE REVIEWS

...cmuindjbnp age 1 application. Thus, these class extensions also are susceptible tions, a second maybe working on database aspects, a third to the same versioning rituals and are also subject to peer re- may be working on the , and yet another person view. I now collect all the [For Review] applications and build may be working on error management and exception han- a configuration consisting of these applications. ENVY em- dling. In programming terms, we then create separate compo- ploys the notion of a configuration map to group related sets nents in our development environment. In ENVY, the term of compatible applications. You must specify the particular used is application. An application represents a collection of versions of the applications that are released into the configu- classes that together setve some useful purpose. A complete ration map. Accordingly, I now construct a configuration system would then be constructed from a number of such ap- map, called Credentialing System, for example, that consists plications, each of which represents a standalone piece of of the [For Review] versions of the associated applications. I functionality. We use the term com@nent as an umbrella con- now version the configuration map itself with the same [For cept that covers classes, sets of related classes (applications), Review] label. and sets of related applications (configurations). At this point, I inform a technical peer, say Joe, that he should review all the software contained in the Credentialing System configuration map. The specific version of the configuration that he should review is the one labeled [For 66 Review, Mar 22]. Depending upon the bulk of the code to be reviewed, it may take Joe anywhere from two days to a week The critiquing process is very to review it. The amount of code to be reviewed should be of similar to the original coding process; it manageable size; the reviewer should be able to do the job in two or three days. has the same look and feel. After I have submitted all my code for review, I can con- 99 tinue developing my components without waiting for the re- view results. Basically, I start a branch from the [For Review] version, and continue on a stream of development. Joe starts from the same version and opens up a parallel stream of devel- THE MECHANICS opment where he’ll carry out the review activities. What are The mechanics of the review process consists of at least these review activities? This is the topic of the next section. three steps: THE CRITIQUE AND REVIEW PROCESS 1. Preparing the components for review Following our example, the reviewer loads the Credentialing 2. Actually reviewing the code System [For Review, Mar 22] configuration into his Smalltalk image. He creates a new edition or working COPY 3. Integrating the review results into the next version of of all the applications in the configuration. For the reviewer the component to do an adequate job, there need to be some commonly ac- The review process begins when 1, as the author of a com- cepted guidelines for critique and review. We will discuss ponent, assess it fit for a peer review. This happens when I guidelines in a subsequent section. The critiquing process is have implemented many of the classes corresponding to the very similar to the original coding process; it has the same objects that I have discovered through the initial analysis and look and feel. You are adding comments to and changing, design phases. At this point, all the details may not have been improving, deleting, reformatting code, etc. in the classes us- completely fleshed out. I version all of the classes in each of ing the same browsers and tools the original authors use. The my applications with a distinguishing vetsion label: [For Re. significant thing to note here is that the reviewer is in place view, Mar 22]. During development, we have adopted the adding review comments in the body of the method or even convention that we version all our components using a styl- fixing the algorithm or the control structures within a ized date stamp: [Mar 22], Nay 02, 7 PM], etc. This is intu- method. The reviewer can factor code bettev he can add itively more meaningfirl than version labels such as 0.99, new methods that may serve as code factors. He can delete 0.995 etc. Of course, when we make our external release for methods that he considers obsolete or otherwise unneces- customers, the labeling follows more conventional guidelines. sary, He may add review comments in the body of the Having labeled all of the classes with the [For Review] method, just like he would add a regular method comment. timestamp, I then label the version of the applications con- He can reformat the method or introduce better indentation taining the classes with the same label as that of the classes. It to make the code appear more perspicuous. is important to note that under ENVY, even methods added All these give rise to a nice asynchronous review process to classes that are defined outside of my component (e.g., that doesn’t impact the stream of onward development by a. stream, String, CoUefion) are maintained in the context of the the original author, The reviewing activity seems very much THESMALLTALKREPORT like coding, except that you are now largely reading someone else’s body of code and applying your critiquing skills to it. The desired result is for the technical team as a whole to produce deluxe, sterling code. It is incumbent on the re- viewer to bring to bear on someone else’s code all the good programming practices he has learned over the years. The id.

66 When instituting a code review process, the organization must a priori agree upon the guidelines with respect to which the review is to be conducted. 99

irrms he has learned to express a certain piece of computa- tion may be far more elegant and efficient than ad hoc “hammer and tongs” spaghetti code. This is particularly a problem with new Smalltalkers schooled in procedural thinking and those unfamiliar with the highways and byways of the class libraries. The reviewer is able to transfer Smalltalk programming nuances hitherto unknown to the versioned [For Review, Mar 22]. He then goes about system- author of the code. atically incorporating the changes suggested by the reviewer. When the reviewer finishes going through all the classes in In some cases, this may involve a merging of the two ver- each of the submitted applications, he versions all the classes sions of a method, If the reviewer has produced a new ver- he has touched with a new distinguishing version label: [Re- sion of a method that the author deems superior to his origi- viewed, Apr 10]. In turn, he versions all the affected applica- nal version, he folds the new version wholesale into his tions with the same version label. Finally, he versions the sub- working copy of the class. In many cases, the reviewer may mitted configuration map (Credentialing System, in our simply have made some suggestions or requested the author example) with the [Reviewed] label. The original author is in- to clean up the code in some way. h is then up to the author formed that his code has been reviewed and the results of the to respond to these suggestions appropriately. Quite often, review are in Credentialing System [Reviewed, Apt 10]. the reviewer may have misunderstood the intent of the par- ticular technique the author has employed. In such cases, THE INTEGRATION PROCESS the author may choose to ignore the reviewer’s suggestions. When the reviews come back (in the form of newly ver. It is also possible that the fix the reviewer suggested would sioned components), the author uses a variety of differencing have an adverse impact on a lot of the client code that the tools to quickly pinpoint the areas of code that have been reviewer is not aware of. critiqued. If he agrees with the proposed changes, he can To close the loop, the author, after systematically going fold them into the next version of the component. This is through the reviewer’s feedback using differencing browsers, easily done with environments such as ENVY that provide a produces a new version of the component. It is quite possible rich set of tools that can be used to quickly browse through that the author has added new code to the [For Review] ver- the differences between any two versions of a given compo- sions of the components since he submitted the code and re- nent. The author, for example, would do a Browse Differ- ceived the reviewer’s versions. Now that he has finished inte- ences between the [For Review, Mar 22] version of his appli- grating the reviewer’s comments, it is an opportune time to cation and the [Reviewed, Apr 10] version. The differencing integrate the code developed since the time of submission. So- tools pinpoint the precise differences between the original phisticated programmers may choose ever so slightly different method and the annotated method. ways to integrate the new code, Thus proceeds the evolution To start off the integration process, he opens a new edi- of the software components—an evolution enriched by the tion or working copy of his application that was originally collective insights of the author’s peers. 9.

VOL. 1, lVo. 9: JULYIAUGUST1992 ■ PEER CODE REVIEWS

Ultimately, the author can submit his increasingly pol- assertions. Implementation notes on why a particular data ished software to a different set of reviewers. The new review- structure has been chosen can also be helpful. ers will have the benefit of the first reviewer’s insights and do ● Gratuitous comments. This is the other extreme. Code not have to hoe the same row. They may shed completely dif- thar is extremely clear and self-documenting doesn’t need ferent perspectives on the submitted software. This can only comments that add no value: improve the quality and maintainability of the software. In addition, the code repository now contains a complete audit foa anlnteger trail of the evolution of a software component, including all “Setfooto anIrrteger.” its review versions. foo := anInteger

iesrlitile REVIEW GUIDELINES “Returntilse.m When instituting a code review process, the organization “false must a priori agree upon the guidelines with respect to which . Misleading commerws. Code doesn’t reflect comment or the review is to be conducted. Failure to do so causes tension vice versa. Often, comments refer to method parameters and misunderstanding among team members. A big part of that have long since been replaced by something else, but the code review pertains to coding style. This has been amply the comments themselves haven’t been updated. The other covered in the Smalltalk with Style columns in previous is- common infraction is that the comment claims to do one sues of THE SMALLTALKREPORT.1c2 The Smalltalk style issues thing, while the code does something else: include proper code indentation, choosing proper variable names, good method comments, and so on. We enumerate ati anAaaoc some of the empirical guidelines that we employ in the re- “AnsweranObject.AddanObjectto the receiver view process below. if the receiver does not alreadycontain it.” “Savein the hades table” Iokl BASIC GUIDELINES Cu.rsor14anagerexecute change. What to watch out for in a code review: hader quey: (self update:arulasoc). ok:= hader FetchResults. ● Poor indentation. This is the culprit in a lot of sloppy CursorManagernormal change. code. Proper indentation makes the code clearer and a “savelocally” pleasure to read. Indentation also gives rise to heated dis- (rtievedAUPlag I cachel%g) agreements among team members. “Hey, that is my per- WI’rue:[super add:anAssoc]. sonal writing style. Don’t mess with it.” Good, reusable ‘ok classes have lots of readers. Think about the users who Bad comment-it refers to an olxolete argument and claims will have to read your code long after you have left the to return one thing, but actually returns something else. scene. A little uniformity and consistency in style goes a long way. The Smalltalk with Style guidelines are cer- ● Cryptic comments: tainly a good place to start. Writers and editors often ad- M al,inlceok ColNbr here to the guidelines in THE CHICAGO MANUAL OF “Returncolumn dab” STYLE or THE ELEMENTS OF STYLE by Strunk and White \ for similar reasons. ● Annoyingly informal comments. “Can you believe XYZ Co. did this? Sheesh!” “Joe really messed this up,” “If the ● No class comments. Standard Smalltalk/V does not have poor sap gets to this method, he’s really asking for it.” tool support to embed class comments. Several commer- Such comments may be okay and may even promote cam- cially available development environments, however, do radarie if the software is going to be used only within your have explicit tool support to add class commerm. Use limited workgroup, but for production quality software them. A good class comment should pithily describe its that will be used by anonymous customers, it represents poor taste. purpose and how it is intended to be used. Additionally, it can also include some global implementation notes, a de- ● Bad argument names. Beginning Smalltalkers, particularly scription of irs instance variables, and any special algo- C programmers of the argc-argvschool, commit this viola- rithm used in implementing the class. tion frequently. Using nonintuitive argument and variable names like erg, apamr,parml, pannz, trnpl, ~p2, or even ● No method comments. It is frustrating to figure out the anObject doesn’t serve anyone. h is a nightmare to figure out intent of a long rambling method if it doesn’t have accu- the classes of the objects that are participating in the com- rate comments. Even well-written methods can use com- putation. Likewise, method selector names shouldn’t be ments to explain operating conditions, and pre- and post- misleading; they should be intention revealing. 10.

THE SMALLTALKREPORT WINDOWBUILDER The Interface Builderfor SmalltalklV t!)

The key to a good application is its user interfnce, and the key to good interfaces is a powerful user interface development tool. For Smelltalk, that tool is WindowBuilder.

Instead of tediously hand coding window definitions and rummaging through manuals, you’ll simply “draw” your windows, and WindowBuilder will generate the code for you, Don’ t worry — you won’t be locked into that first, inevitably less-than-perfect design; WindowBuilder Inm!===j allows you to revise your windows incrementaUy. Nor will you be forced to learn a new paradigm; WindowBuilder

H-id - oh, generates standard Smelltalk code, and fits au seamlessly into the Smalltalk environment as the class hierarchy browser or the debugger.

Our new WindowBrrilder/V Windows 2.0 is now available for $149.95, and WindowBnilderN PM i, $295. Both E21iliiw&--products include Cooper & Peters’ unconditional 60 day -- -- guarantee.

“... this i. a potent rapid application development tad which For a free brochure, callus at (415) 855-9036, or send m a mhozdd be included h any SmaUtalkN developer’s environment.” fax at (415) 855-9856. You’ll be glad you did! - Jim .%bFwm, The %rdltalk Report, September 1991

COOFEI h Pmems,INC. [FOWEUV ACUMENSOFIWAREI 2600 EL CAMINU REAL, SUITE409 Pun ALTO, CALIFORNIA 94304 PHONE415 B55 9036 FAI 415 855 9856 COMWJSEWE71571,407

● Coding anachronisms. This is a case of old habits dying do a lot of things. Often, you expect a certain responsibil- hard. New Smalltalk releases and development environ- ity to be discharged by a certain object; instead, in code it ments often introduce new programming idioms. Always manifests itself as a complicated multi-keyword method accessing classes through symbols—e-g., (Smalltalk at: that requires a lot of hand assembly to use. Reviewers can #HeatingUnit) raiseTempetature-is no longer necessary suggest, in such cases, how these methods can be rewrit- if the development environment allows you to explicitly ten, refactored, etc. specify class prerequisites. Furthermore, cross-referencing . Defensively lodging “global” behavior in Object. If a cer- facilities such as browse methods that reference the class tain behavior is expected to be global within your partic- HeabngUnit will not show up this method since the class ob- ular domain, find an appropriate class in your domain to ject is buried inside a defensive expression. If I were to re- lodge this behavior. If every class in your domain must name the class HeatingUnit,I might miss making a change have this behavior, create an abstract superclass that con- to the method, and that will cause a nmtime error in the tains this method and have every one of your classes in- future. Referting to classes indirectly through class names herit it. Alternately, you can lodge this behavior in a goes against the grain of classes as fitst-class objecu. Of class method of an appropriate class in your domain. course, there may be exceptional conditions under which Blindly putting the behavior in Object causes all classes in this may be warranted. the system to be susceptible to any side effects that it may ● Using needless temporaries. Beginning Smalltalkers tend cause. Reviewers may suggest alternatives appropriate to to gratituously use temporary variables to do iteration. the context in which the code is meant to be used. There are a phalanx of iteration idioms like co~~eti,select, ● Put global class methods in Behavior,not Object. I have injectinto: that do the job more efficiently and make the in- come across several Smalltalkers who put catch-all class tent of the code clearer. behavior in Object.This is too defensive. Behavior is the . Needless multiple exits from a method. Another defensive root superclass in which you should lodge behavior that is programming malady that could be remedied by proper use expected to be inherited by every class in the system. of the conditional control constructs and good indentation. ● Unnecessarily using isKindOfi, isMemberOfi. This is not con- ● Poor distribution of responsibilities. This is really poor sidered good programming style. You are referring to a class design that percolates into the coding process. This mani- directly via a hard constant. This is not only inefficient, fests itself in heavyweight classes with 100 methods that but also less reusable. Instead, use polymorphic test mes - 11. VOL, 1, IVo. 9: JULYIAUGUST] 992 ■ PEEFi CODE REVIEWS

sages: isstig, isNurseetc. In this case, you’d implement is- intention must be expressed via appropriate programming Wing methods in Objectand string, returning faLseand hue, idioms. Smalltalk/V has irnplementedBySubclassand Object- respectively. If you are sure that the receiver of the isKindOfi works for Small talk has subclassResponsibilitymethods for method is going to be an object of a class that is directly or such purposes. Putting self halt is not acceptable. Similarly indirectly inherited by a particular superclass, then put the for subtractive inheritance, Objecworks provides a should- false test method in that superclass. For example, if you are Notlroplementidiom. sure the receiver is always going to be some kind of a sub- ● Putting self halts to trap exception condition is not accept- pane, put the fake test in SubPane, not Object. able. While this condition may not manifest in the course of normal developer work, the moment it hits the cus- tomer’s hands, it is sure to trigger the exceprion and cause 66 an unpleasant walkback window to pop up. As far as possible, code should be ● Using inappropriate data structures. Programmers often use familiar data structures because it gets the job done. A very optimized for the environments that it is common example of this is the use of the class OrderedCoUec- supposed to work on; platform differences tion. OrderedCoUecbonis very malleable and very flexible. It responds to a wide variety of protocol and is a friend of the should be dealt with by partitioning code defensive programmer. However, all this comes at a price: into platform independent and platform space and time overhead. In cases where it is clear that a fixed size collection can do the job, Arraysshould be used. In specific portions. cases where elements in the collection are retrieved in 99 batches, a I.inlredListis perhaps a more appropriate data structure. Reviewers should be on the lookout for this.

● Defensive parentheses that do not contribute to code clarity:

. Archaic, old, effete code should be weeded out. Code (aValueisNuUValue) should keep step with emerging idioms, and newer and Wrue:[”aValue], better features in the underlying class libraries. For exam- (aValueisNuUValueor [(aValueisKndOfi DateTime)]) ple, if a new version of your base environment provides ifTnre:[AaVahre]. richer protocol to insert an association in a dictionary use A hopefully better rendition is: that. It would make your code more compact. For exam- ple, ENVY has a Dictionary method atifAbsentPuti, so code ‘(aValueisNuUValueoc [aValueisDateTime]) that is originally written as: ifhue: [aValue]

● myconstants:= SmaUtaUr Use CharacterConstantsor messages instead of literals to ah #MyConstants represent characters. This makes it more readable. $ is ifAbserrk[Smalltalkat: #MyConstants less readable than space or Characterspace. puti #(a b c)] ● Use streamprotocols instead of lengthy concatenation can have a more modem rendition of strings.

myconstants:= .%ndkah . Use nonevaluating conjunctions or disj unctions for some at ?MyconstantsifAbsentPub [#(a b c)]. ifl’nre:fiake: blocks that return booleans:

A common counter argument to this guideline is, “Hey, I Badcode have to make my code work under multiple environ- aBoolifl’rue:[“5] ifPalse:[“false]. Goodcode: ments.” This means programming to the least common de- ‘aBool and [5] nominator of available idioms. As far as possible, code should be optimized for the environments that it is sup- posed to work on; platform differences should be dealt with ADVANCED GUIDELINES by partitioning code into platform independent and plat- ● Inefficient algorithms. Reviewers should watch out for non- form specific portions. ENVY, for example, provides ex- polynornial time algorithms and should suggest faster algo- plicit tool support for cross-platform development. rithms if one exists as opposed to, say, 0(n3) algorithms.

● Writing “to be implemented by subclass” in the comment ● Poor factoring of code. and then not expressing that intent in code. If a method must be implemented in each and every subclass, then that ● Poor construction of inheritance hierarchies. 12. THESMALLTALKREPORT ● Poor separation between platform-specific and platform- independent code. It is poor practice to partitioning plat- form-specific code across classes (a Universal Database concept) as opposed to across applications (a program- ming environment concept ). OBJECT BRIDGE “ This developer’s tool allows Smalltalk to read and write to ● (Im)proper partitioning of methods into public and private ORACLE, INGRES, SYBASE, SQL/DS, DB2, RDB, RDBCDD, methods. For example, initialize and release methods dBASEIII, Lotus, and Excel. should be private. . Proper initialization and destruction of data structures (ini- ntelligent Systems, Inc. tialize and release). H S4MN.310te Street,Ann Arbor. M14SlC14(913) WS-423S(313)W6441 fmt

good programmer accrue to other less experienced program- 66 mers on the team. Code reviews should be viewed as a rigorous software en- Just as a good general makes the soldiers gineering activity, not a mindless chore undertaken half- around him better, so, too, should the heartedly to adhere to some “feel good” corporate software development guidelines. Good Smalltalk programmers tend benefits of having a good programmer to read a lot more than they write. They tend to adopt the accrue to other less experienced idioms of other good programmers while inventing a few of their own. Ward Cunningham once observed, “Good class programmers on the team. libraries whisper the design in your ear.” While browsing 99 through other people’s code, I often say to myself, “That’s a great idea! why didn’t I think of that?” Kent Beck has termed these voyages of discovery the “Aha ! experience. ” 3 Well-written code is a pleasure to read, and it becomes ● Messages sent but not received (implemented). This is a quickly apparent if a class is reusable or not. People try to potential nmtime error. imitate and emulate well-written code. Well-organized code ● Messages implemented but not sent. This is quite possible, reviews have the benefit of bringing to bear every team if the component is intended to be used as an extensible member’s perspectives and experiences to the total quality of framework. However, if you are delivering a standalone ap- the software being shipped. Even with a cohesive review pro- plication, these methods are candidates for elimination. cess, there are plenty of ways in which team members can You should make sure they are not called via perform:. express their own unique styles in the delivered code. Good software engineering practices as expressed in Smalltalk code SOCIOLOGICAL EFFECTS can only propagate the positive effects and thus result in T’he impact of the code review process as described in this ar- more gratifying Aha! experiences for everyone. ❑ ticle is most effective in organizations that actively encourage programmers to critique each other’s work. On the other REFERENCES hand, in workgroups that have a “cream puffs, marshmallow” 1. Klimas, E., and S. Skublics, A matter of style, THESMALLTALK culture, there is probably a fine line, the crossing of which REPORT1(2):1-5, 1991 may yield undesirable sociological results that counter the 2. Klimas, E., and S. Skublics. Tips for improved Smalltalk reuse and benefits of a stringent code review. Recently, while drawing reliability, THESMALLTALK REPORT1(6):11-14, 1992. up a blueprint of Smalltalk software development for his company, an MIS manager commented, “Of course, we are 3. Beck, K. Essaysand A-Has, HOOPLA! January, 1988. going to write good code. Peer fear will ensure that nobody writes sloppy code.” Organizations and workgroups that can S. Sridhar is a senior member of technical smff at Knowledge Systems distinguish between an honest critique and a personal barb Corporation in Cmy, NC, where he is actively applying Smdtak m a are most likely to benefit horn a rigorous review process. It is variety of softwareengineering problems. He came to KSC from Men- also likely that some developers will be more reluctant than tcrrGraphics Corp. where he was the Project lead for Mentor’s second others to submit their code for review. This happens for a va- generation designrrumagement environment developed in C++. Prior riety of reasons, not the least of which is a fear of being unfa- to that he worked at Tektronix, hrc. for four years on Common Lisp vorably critiqued, Just as a good general makes the soldiers and SmaUAU/80 product&ue@mvznt. He can be reached at around him better, so, too, should the benefits of having a 9J9.48f.4ooo. 13, VOL. 1, No. 9: JULY/ALIGUST1992 HE BEST OF comp.lang.smalltalk Alan Knight

What’s wrong with 00P?

hings object oriented have been receiving a lot of at- This is a typical “OOP novice” question. Surely people tention lately. Some is justified interest in an impor. wouldn’t devote so much effort to selling you something that T tant emerging technology, but a lot of it is just hype. It didn’t have drawbacks. Is the learning curve too steep? I’ve is apparent that in some circles, “object-oriented” has become heard it’s inefficient. Are the claims of easier maintenance the buzzwordof choice. and reuse borne out in practice? If 00P encourages reuse, Everywhere you turn things are described as object oriented. how come there isn’t more of a software components industry? Operating systems, windowing environments, and programs of Are there real companies doing major projects with 00P? every description are now labeled O-O. There’s more restraint What kind of success stories or disasters have there been? with programming languages, perhaps because there’s a clear Let’s start with the disasters. One well-publicized failure definition of what an object-oriented language is. For pro- occurred at Cognos, an Ottawa company that makes 4GL grams, it’s only necessary that the designers think about the tools. A few years ago they tried to switch from C to Eiffel as problem in an object-oriented way, or that something in the the implementation language for their main product. The program be called an object. project ran into severe difficulties and was eventually aban- At the same time, object-oriented programming, design, doned. Burton Leathers is a Cognos representative who has analysis, databases, graphics, and other functions are pre- spoken and written about the project in several places, in- scribed for all problems. There is a silver bullet, we’ve got it, cluding an article in the July 1990 HOOT (HOTLINEON and for only a few dollars you can have your own compiler! OBIECT-ORIETNTEDTECHNOLOGY).The problems with the Triple your productivity overnight ! Plus, if you act now, project are said to include immaturity of the Eiffel tools at we’ll turn software into a rigorous engineering discipline at the time it was undertaken, the attempt to move wholesale no extra charge! Even the editors of BYTE magazine, who re- into 00P without adequate preparation, and general bad ally should know better, write about how 0-0 promises to management. The order of importance of these factors de- make computer programming accessible to the right-hemi- pends on who you talk to. sphere, creative people who have traditionally been ex- On the other side, there area lot of 00P success stories. A cluded. I could go on about that one for quite a while, but particularly impressive one involving Smalltalk was recently de- 1’11restrain myself. scribed on the net by Bruce Samuelson ([email protected]. edu), This much hype inevitably provokes a backlash, Those who credited the May 11th COMPUTERWORLDmagazine as the who have already embraced some other method of saving the source. A company named EDS (Electronic Data Systems) re- world resent 00P’s popularity and look for flaws. Others cently did a test project, rewriting a system using PL/1 and a re- without detailed criticisms nevertheless remain skeptical of lational database into Smalltalk with an O-O database. The the inflated claims and suspect hidden drawbacks. The rest of PL/1 system was quite new, so specifimtion, design, and test this column may remind you of a few arguments you’ve been documents were still available, as were the original implemen- in, as I’ll be going through some representative questions and tors. Using a team experienced with Srnalltalk, they achieved criticisms, with comments and some of the replies. If you incredible productivity gains on the order of 14:1. I haven’t haven’t yet had to deal with these, perhaps you’ll be better seen this confirmed, so if you want to use it as an example, it prepared when the time comes. would be best to check the details.

WHAT’S THE CATCH? MAINTENANCE AND REUSE Devon T. Caines ([email protected]) writes: One of the principal claims of 00P is that it allows easier maintenance and code reuse. These are not easy things to Just one quickie question. measure, and 00P detractors often argue that these gains are What are the real disadvantages of 00P? There must imaginary. be a down side. True, the learning curve is one, but I For example, Ravi Kalakota (kalakota@ut-emx. uucp) don’t consider that serious enough. wrote: 14, THESMALLTALKREPORT The oft-cited advantages of the O-O approach have been the other hand, a language based on C, with all of its “fea- code (and design) reuse, easy extensibility and tures,” doesn’t appeal to me either. Call me spoiled, but I modifiability. O-O has brought about subshntial reduc- like arrays that know their own size, and I like languages tion in the size of new code that has to be generated and that at least allow for the possibility of runtime checks. I also the size of the overall system. As the code size be- know that in C++ it’s possible to write or get hold of array comes mote “concentrated,” the complexity of the sys- classes that work properly, but the default is still C, and a lot tem increases dramatically (at least in my opinion). Does of code uses the default. this complexity affect maintenance? Probably not in a simple project. But in a large system . . .. 66

Perhaps because these things are so hard to measure, they Call me spoiled, but 1 like arrays that attract a lot of interest on both sides. There were a lot of anec- know their own size, and I like languages dotal stories posted, as well as references to several studies pur- porting to prove either that O-O improved maintenance or that at least allow for the possibility of that it made,it more difficult. Many disagreed with the basic runtime checks idea of this post that complexity necessarily increases as code 99 size is reduced. The general perception is that in normal cases reduced code size reduces complexity. In APL, for example, part of the reduction in code size is due to the use of one- character identifiers, which certainly reduces readability. Even Of course, there are people who like C, and many of them there, though, most of the reduction is due to the language really like it and don’t see why you would ever want another providing very powerful operations. language, even one as close as C++, Martin A Leisner (leis- There was a strong consensus among all parties on the idea ner.henr801 [email protected]) writes: that maintainability is not an inherent property of 00P is a buzzword for “good design practices” . .. . I’ve any programming language or paradigm. There have been bad been doing OOP in C for years (C++ just enforces more programs written in 0-0 languages, and will undoubtedly be a disciplined programmer doesn’t need). If 00P helps many more in the future. Designing for maintainability is the make good designs, great. But good designers make good essential part of building a maintainable system. Whether O- designs, not the language/system. 0 methods really assist in this or not remains in dispute, and likely will until many more studies have been done. I have to agree that good designers are important, per- As Ralph Johnson ([email protected]. edu) writes: haps even more important than good languages. However, from my own experiences in having to do some work in C You can build poorly stmctured systems in any lan- for the past couple of months, I (speaking as a good de- guage. The question is whether you are able to build signer) am getting extremely frustrated with the lack of well-structured systems. both 00P and software engineering facilities. One way to I build well-stmctured systems in Smalltalk that are rel. make C++ look good is by writing in plain C. The inability atively easy to understand. My feeling is that 00P makes to generalize operations to work on different types, the it easier to build well-stmctured systems. It is easier to see need for function pointers everywhere, and the lack of en- the design, so there is more motivation to do it right. forcement on information hiding all make it very difficult. Ralph Johnson ([email protected]. edu) had a particularly 00P 1S UNNECESSARY good line for this: Then there are those who actively try to find fault with partic- Information hiding can be implemented by self-restraint. ular aspects of 00P. Some claim that most of 00P is not re- You can tell yourself that clients should never use a par- ally new, and that the new parts are not important. In this ticular fact about a component and then believe yourself view, the productivity gains claimed for 00P are primarily a when you design the components. Self-restraint works result of its use of standard ideas on abstract data types and in- almost as well for implementing information hiding as it formation hiding. Inheritance and dynamic binding are con- does for birth control. sidered to be either insignificant or actively harmful. This type of argument often occurs in a discussion of the C is a pretty easy target, so it’s not really fair to take that as relative merits of Ada and C++. This is one argument where our representative non-O-O language. Suppose we use Ada I don’t have a strong opinion. I’d hate to have to work in a instead, which does have support for information hiding, language without the O-O features I’m accustomed to, even genericity, and many other nice features. Does the full power if it did embody good software engineering principles. On of O-O really gain us much over this? 15. VOL. 1, No. 9: IULYIAUGL’ST1992 ■ THE BEST OF COMP.LANG.SMALLTALK

Peter Hermann ([email protected]), who appar- gerous” as well? This has been discussed in the O-O commu- ently doesn’t think so, writes: nity for some time, and there seem to be two main issues. The first is inheritance for subtyping vs. inheritance for code reuse. In an exceUent paper “Object Oriented Extensions to On this, Ralph Johnson (who I keep quoting because he keeps Ada: A Position Paper for O-O Ada Panel” TRI-Ada ’90 writing good stuff) writes: p.92-94 ISBN 0-89791 -409-0 Schwartz, Jack H. wrote: Conclusion: The current definition of the Ada language I see the use of inheritance as one of the differences be- already includes the best features of object-oriented lan- tween people interested in developing reusable software guages, namely: and those interested in getting applications out the door.

● modularity People who are good at developing reusable software ● encapsulation want to develop elegant software and dislike using inher- ● separate compilation itance just for code reuse. However, people who want to ● genericity deliver applications as soon as possible think that over- wdynamic instantiation riding arbitrary methods is the greatest thing since text ● lexical overloading editors. Both are right. They have different goals, and wexception handling thus different criteria for evaluating programs.

Inheriting for code reuse is fine in a prototyping environ- ment, but those sorts of relationships shouldn’t normally make it into production code. The standard Smalltalk example of 66 this sort of inheritance is Dictionay being a subclass of set, Certainly inheritance can be badly even though the interfaces are quite different. This relation is misused by the inexperienced or by the now enshrined in tradition, but to my mind it would be much more sensible for both to be subclasses of collection, imple- experienced in a hurry. Does that mean it mented in terms of a third class HashTable. This would achieve should be left out of a language? roughly the same level of code reuse, make the operations of 99 Set and t)itionary trivial, and make it much easier to write sets or dictionaries with alternative implementations. One reason this sort of thing doesn’t get done is simply laziness on the part of the programmers. It’s easier to inherit and deliberately excludes many questiomble and danger- and change the interface than to write a new class, and there’s ous features such as a reluctance to write classes that do little more than translate their operations directly into an underlying representation. ● inheritance Programmers will use an OrderedCollefionto implement a stack ● dynamic binding rather than writing a Stack class, even though OrderedCollecbons for the very reason that they compromise the require- have many operations inapplicable to stacks. One of these op- ments of large scale software engineering. It is, therefore, erations applied anywhere in the code could lead to a very inadvisable to attempt to extend the Ada language to in- hard-to-find error. clude features that conflict with Ada’s primary goals: The second issue is that of composition vs. inheritance, maintenance, reuse, and progmmming-in-the-large. which is closely related. If you shouldn’t inherit for code reuse, then to reuse code you have to build new classes that This paper, oddly enough, seems to consider things like encapsulate the code you are trying to reuse. This can be done separate compilation and exception handling to be features of by writing a class around an ADT as in a stack implemented object-oriented languages. I’m not sure if that was an attempt by an OrderedColletion.h can be done by writing a class that to minimize the importance of inheritance and dynamic bind- includes instances of several other classes and manages the re- ing by placing them amid a long list of features or if it’s due to lationship between them (I’d say this was the normal case in just listing all the features in C+ + and attributing them to 00P development). Or it can be done by writing classes that 00P, That aside, this post does raise the interesting question manage somewhat arbitrary collections of components (such of how important inheritance and dynamic binding are to as a windowing class that manages a group of sub-windows). 00P, and to good software engineering in general. Richard Thomas ([email protected]. au) writes:

INHERITANCE AND DYNAMIC BINDING CONSIDEREDH~ Inheritance is the biggest problem and danger of Inheritance is a very powerful and useful feature, especially in 00P . . ..Most students have problems deciding when to a prototyping environment. Is it really “questionable and dan- inherit and when to import. Often they will inherit too 16. THESMALLTALKREPORT ODBMS much and generate a messy fettuccine (a la spaghetti) class structure. Unfortunately this isn’t limited to stu- dent efforts. Many examples of OOP in the literature and in class libraries use inheritance just about every time they want to access a feature. This is wrong! Overuse of inheritance leads to a very complex, nonin- tuitive class hierarchy that takes a considerable amount of effort to understand . . ..Inheritance for code reuse (not subt yping) allows you to defeat the princi- ples of information hiding. Either I view a subclass on its own and have important features that this class de- pends on hidden from me in superclasses. Or I look at the expansion of a subclass to include its superclasses and have to interpret the entire mess and figure out all the dependencies.

So it appears there is a valid point in the idea that inheri- tance is “dangerous,” Certainly inheritance can be badly mis- used by the inexperienced, or by the experienced in a hurry. Does that mean it should be left out of a language? I don’t think so, but perhaps a language (like Ada) not aimed at pro- totyping situations could provide compiler support for restrict- ing inheritance to subtype relationships. Also, I suspect that Smalltalk is not quite so badly off in this regard as those lan- guages with multiple inheritance, where misuse is that much ODBMS easier and can get that much worse. We haven’t even begun to talk about dynamic binding, The Objectoriented Database which could easily fill another whole column. In the context for W* and 0S/2. of these kind of discussions, full dynamic binding in the style of Smalltalk is generally considered too dangerous, because it ODBMS is passible to have errors which will not be detected until run- ‘Ib make your SMALLTMK even better. time. I find it odd that people do not seem to have the same problem with current computer arithmetic systems, which ODBIUS have the potential to cause very serious runtime errors, but I Objcctoriented Technology by guess they have different priorities. Even limited dynamic Vc SOhareCon!muctiona binding such that is found in C++ and Eiffel is considered dangerous. In a hnure column 1 may go into these issues, but I suspect most of the readers have already made up their minds ORDER NOW ! on this and would be more interested in something else. 0 ODBMS - Programmer’sVersion TO BE CONTINUED o ODBMS - Graphical User Intake This column is already running long and late, and I haven’t o ODBMS - Interfkce to SQL even considered some of the more interesting criticisms and misperceptions. Among these are the idea that O-O implies Cl DSSDe - Distributed Pro~ that only local knowledge can be used, or that strict O-O does based on ODBMS not permit classes representing relationships or processes. ❑ Those issues will have to wait for the next installment. ODBMS and more ...

Alan Knight is a researcher in the Departmentof Mechanical and Aerospace Engineering at Carleton University, Otuwa, Canada, KI S 5B6. He currentlyworkson probkru relad tofinite ekment analysis in ParcPlace .snudhdk, and has worked in.most Snud.ltalkdkdects at oru time or another. He can be reachedat 613.788.2600 x5783, or by end as knighttlmrco.carleton.ca. 17. VOL. i, No. 9: WLYIAUGUST1992 MALLTALK IDIOMS Kent Beck

Abstract control idioms

started writing about the new ValueModel style used in dots have done with code I have modified. If we had a mecha- ParcPlace’s ObjectWorks \Smalltalk release 4 as promised, nism that was like message sending, but was extensible with- Ibut soon discovered that I need to cover some preliminary out modifying the original code, we could gain reusability for material about the “traditional” style first. I split the column our libraries of objects. into two parts. This one talks about how abstract control has been used to date. Next issue’s will cover the new possibilities THE SMALLTALK SOLUTION: UPDATE/CHANGED available with the advent of ValueModels. Update/changed,also known as change propagation or depen- dency, is the Smalltalk solution to a “more abstract message MESSAGES LIMIT REUSE send.” It is more abstract in the sense that zero or more re- Reuse is the name of the game. Headlines shout. Marketing ceivers can be activated by one action in the sendeq the num- literature trumpets. Salesmen ooze. Objects will solve your ber and identity of the receivers is determined at nrntime and reuse problems. Not true, of course. Programmers solve reuse can easily be changed by code which is otherwise unrelated to problems. It is possible to reuse procedural code, and it can the sendeq and the receiver has much more choice in re- be impossible to reuse objects. If the mere presence of ob- sponding to the a changed message than an ordinary message jects doesn’t enable reuse, what is it that makes reuse hap- send. On the other hand, because it is not implemented by pen, technically? the Smalltalk virtual machine it is not as efficient as ordinary Whenever I am able to reuse a piece of code, either by de- message sending. sign or through serendipity, it is because the code makes few I talked to Diana Merry-Shapiro (one of the long-time assumptions about what the rest of the world looks like. A members of the original Smalltalk team) about the evolution graphics model that assumes all coordinates are integers is of rhe dependency mechanism. The early Smalltalkers took as significantly harder to use than one that is prepared to take their benchmark problem a model consisting of a collection of any kind of number. What does this have to do with messages numbers and two views, one a pie chart and the other a bar limiting reuse? chart. The problem was to keep both charts consistent with Every time you send a message you build into your code the the model while leaving the model as ignorant of the fact that assumption that one and only one action will be invoked. it was being viewed as possible. According to Diana, it was What happens when you later decide you need two things to who finally implemented the dependency mecha- happen? Or sometimes none and sometimes many? You have nism as we know it. to change the original code. Here is a quick review of the fundamentals of dependency. I can think of three levels of code reuse. By far the simplest The system associates with each object a collection of depen- is reuse by instantiation. You create an object, send it some dents, other objecn to be notified when it changes. Here is a messages, and good things happen. Far more complicated is simplified implementation: reuse by refinement. To subclass you have to understand the imer workings of the superclass to know what messages to in- ObjeO>addDependentianObject Dependertts“aclassvariablein Obje&’isliil tercept and how to compatibly extend the representation. By ifl’ruw[Dependents:=Identi&Dictionarynew]. far the most expensive reuse in terms of downstream costi is (DependentsinchrdesKey seH) reuse by tweaking. Somehow the original author never factors itFalse: [Dependentsati seti puk Set new]. the methods enough, but by a little judicious editing you can (Dependentsak sew add: anObject create an object you can subclaas for your purposes. Object>>removeDependenkanObject Tweaking is becoming infeasible as a production program- DependentsisNiliflhra [Aselfj. ming strategy. As Smalltalk programs gTow, it becomes in- (Dependentsak self ifslbsenti [%e~) remove:anObject creasingly desirable to treat code from outside sources as im- ifhenk [Aselfl. mutable. I have enough trouble keeping up with changes to (Dependentsak selfJisEmpty my own objecu, much less trying to track what several ven- il’1’me:[DependentsremoveKeysew 18. ‘THE SMALLTALKREPORT Most objects don’t have any dependents, and there is no I have found it good practice to have only a single send space cost for nonpafiicipan~, so the memo~ overhead of de- to self for each case. When I am tempted to put several pendency is not high. statements in the block I invariably end up creating a When an object changes its state in a way that it thinks method later which is exactly those lines. Also, the code is dependents might be intere.wed in it sends itself the message simpler to read if each implementation of update: has the changed, which causu all of the dependents to be sent the same form. message update. Each dependent then takes whatever action What if you want several views on the same model, but you is necessary to reconcile it with the new state. want each to respond to different updates? The old license version 2 image introduced pluggable views to solve this prob- Obje@>dependents lem. Rather than create a subclass for each slight variant, each DependentsisNilWrue: [“#()]. “(Dependents ati sew ifAbsent: [#()] of which would override update:, a pluggable view stores the pattern againat which update messages are matched in an in- Objeb>changed self dependents do: [:each I each update] stance variable. Here is SelefiotdtiVkw, the pluggable vari- of ListView. Obj-wpdate ant “self “Donothing by dei%mlt” updatx a.$mbol a$mbol ==partMsg The smlution to the benchmark problem mentioned above WI’rue:[“self setNewList]. is to make the pie chart and the bar chart dependent on the asymbol==initialSelectionMsg list of numbers. Every time the list changes, adds, or deletes a WI’rue:[“self setNewSelefion] , value, it sends itself a changed message. Both of the views in their update methods simply redisplay and the consistency The instance variables are set when a list is created with problem is solved. The solution has the additional attraction the SelefiofltitWl*>onqetibtibti message. Each list that new kinds of views can be added, and as long as they are also needs to send a different message to the model to get the registered to the model they will operate without any changes contents and set the selection. The symbols used for checking to the model. Finally, the model works in the absence of a user updates double as messages that are sent to the model via per- interface just as well as it does interactively. Because all com- form:. I have always thought this was kind of sleazy, but in munication with the user interface is through dependency, its practice it works quite well. presence or absence makes no difference to the model. The other commonly used pluggable view is TextView. The first problem that becomes apparent with this simple SelehonInL.istView uses one symbol to check to see whether dependency mechanism is that not every dependent is inter- to update the list contents and another as the message to ested in every change. The most common form of changed send to the model to get the list. TextView uses the same message adds a parameter, a symbol by convention, which sug symbol for both (the aspect: parameter of the instance gests the kind of change taking place. The parameter is passed creation message). along to the dependent. Notice that the generic update gets A final note about implementing update: –remember to sent if update is not overridden. send “super update: asyrnbol” if the current method hasn’t con- sumed the updatemessage. That way your classes will fit more Obje*>changed a$snbol neatly into hierarchies. self dependents do: [each I each update: asymbol] I looked through all senders of changed to see if I could find Obje*>update: asyrnbol any pattern to the symbols that are used as the parameter, and self update I wasn’t able to discover anything profound. The parameter Most applications that need dependency can be coded with should, of course, have some relation to the change taking no more complexity than this. place in the model. Other than that there doesn’t seem to be much of a pattern to how the symbols are selected. DEPENDENCY IDIOMS For consumem of update messages, the primary idiom is to DECIDING TO USE DEPENDENCY override update: and swirch on the parameter. Here is If dependency is so cool why not use it all the time? Play- ListVi->update: ground, a language I worked on at ’s Vivarium project, was an attempt to do just that. It used dependency update: asymbol as its only control abstraction. Because Playground was a a$nnbol = #list ifl’rue: [“seLfsetliewhst]. pure abstract control language, it threw the two biggest a$mbol ==#listTndex drawbacks of dependency into high relief: debugging and WI’rue:[“self setliewseleclion] performance. There are two problems with debugging update messages. The first is in the debugger. It takes a long time to single-step 19. VOL. 1, No. 9: JULY/AUGUS~1992 ■ SMALLTALK IDIOMS

through code which does an update. You have to go through sends. Or you may have a collection of rsbjects that all re- all the intermediate steps of the implementation for each de- spond to the same messages, so YOUcan store a collection and pendent. (The real implementation is considerably more com- use direct messages. plicated than the one outlined above. See the section called Gory Details for the, well, you know.) If you have lots of de- THE 00RY DETAILS pendents and only one of them is interesting this can be te- The dependency implementation in Objectworks\ Smalltalk dious and frustrating. release 4 is more complicated than the one outlined above. The browseralso does little to help debug dependency. If There is a varianr of the update method that takes three pa- you have symbols built in to your implementations of update: rameters: an aspect, an oprional parameter, and the changing you can at least use senders (from the Iauncher window) to object. Changed sends changed:with:, which sends find out where they are used as parameters to changed. If you update:with:frorrr: which by default sends update:with: which are implementing a pluggable view, however, the symbol will sends update:. All of these intermediate steps add greatly to only show up in the user interface code which creates the the functionality and complexity of dependency. However, in view. From this it is often hard to see how an update will my opinion, if you use all the available generality of the three- be triggered. A trick I use is to add “fianscsipt cr; show aSyrn- parameter version rsfupdate you are stressing what was in- bol” as the first line of the update: method I am interested tended to be a very simple mechanism, and you are likely to in. I can then see all the update messages and the order in run into trouble. which rhey arrive. The implementations of addDependent:and removeDepen- A less compelling, but occasionally fatal, drawback of de- denk in Objectare much like the ones above. They have a seri- pendency is performance. Unlike a message send, which every ous flaw. If an object has been registered as a dependent and it part of the Smalltalk implementation is tuned to make fails to remove itself, or if an object gains dependents that are efficient, changed messages have to go through several layers not removed, it cannot be garbage collected because it is re- of invocation to get to their recipient. If you have lots of de- ferred to from a global variable. To deal with this problem, pendents, most of whom aren’t interested in most updates, you there is a subclass of Objectcalled Modelwhich adds an instance can spend enormous amounts of effort creating a little activ- variable, dependents, and overrides addDependenband re- ity. A related minor annoyance is that all those layers of invo- moveDependenti.Since the model is not referred to globally, it cation tend to clutter performance profiles, especially if you is easier to get it garbage collected; once it has been collected, have several layers of updates happening. it no longer refers to its dependents, so they become candi- Since dependency has significant costs associated with it, dates for collection. when is it worth using? The one clear case is when you are im- A final nuance of the implementation of dependency is the plementing new views or models. You need dependency so use of DependentsCollection,a subclass of array. If a Modelhas your code fits well with the rest of the system. Also, depen- only a single dependent the value of its instance variable de- dency makes your models more reusable by insulating them pendentsis that dependent. Object>>changed:witi sends from the precise details of the interface or interfaces that are update:with:from:and off ro that dependent and everything viewing them. works. If there is more than one dependent then dependents is Other than models and views in the traditional sense, you a DependentsColleclion,which overrides update:withxlom:to for- should use dependency anywhere you want art object to be ward the message to each of its elements. This little trick saves thoroughly insulated from the environment in which it oper- an additional object when rhere is only one dependent. ates. Any object that you know will be used in a variety of ways and that you want to keep clean is a candidate for dependency. CONCLUSION When is dependency being abused? Here are some signals We have seen how abstract control structures, implemented that you have gone too far: by Smalltalk dependency mechanism, can reduce the strength of the connection between two objects. This can lead to en- ● An action spawns several updates and their order matters hanced reusability. Because it is outside the language and is ● You forget which symbols mean what not directly supported by the programming environment, ex- cessive use of dependents can make programs hard to read and . Your update messages create an infinite loop debug, and can lead to performance problems. ❑ c You find update messages that aren’t handled by anyone

When your code begins exhibiting any of these symptoms, Kent Beck b been discovering Smalkalk idiomsfor eight years at it is time to revisit the decision to use dependency. You may Tektronix, AppleComputer, and MasPars Computer. He is ah the discover that one of the connections you are making always founder of First Class Software, whichdevelopsand dism”butesre- works out to use exactly one object, in which case you can re- engineeringproducts for Srmdhdk. He can be reachedat P.O. Box place the dependency with a direct reference and message 226, Boukkr Creek, CA 95006 or [email protected]. m AU.

THE SMALLTALKREPORT ,Jzanita Ewing

Creating subclasses

lass hierarchies are a way to capture variations and havior of the new subclass. In this heuristic you must look at specializations. A subclass is generally a more special- the methods or good documentation for the methods. Often, Cized kind of entity than its superclass. For example, just the message selectors will give you enough information to the class Sphereis a subclass of the class Solid. If we needed a reject many inappropriate classes. representation for pyramids, we would create a new subclass, Pyramid,whose superchsss is Solid. BEHAVIORAL INHERITANCE VS. In this example it is easy to decide how Pyramidfits into the IMPLEMENTATION INHERITANCE hierarchy because there is an abstract superclass, This abstract The two heuristics we have presented are oriented toward superclass is a generalization representing different kinds of class hierarchies based on behavior. This kind of inheritance solids. Often the decision about where to insert a new class in is known as bekiorcd inhet-itunce.In these hierarchies a sub- the hierarchy is not straightforward. This column explores class and its superclass have a subtype relationship. That is, strategies for placing subclasses in a hierarchy and conse- the subclass supports all the behavior that the superclass sup- quences of the placement. ports, and the subclass can add new behavior. Any use of an instance of the superclass can be replaced by the use of an in- BENEFITS stance of the subclass. Some examples from Smalltalk class li- Well-formed class hierarchies are those in which functionality braries are: RecordingPen is a subclass of pen, l’ime is a subclass of is factored into a number of classes. Subclasses are specializa- Magnitude, Integer is a subclass of Number, and WlldPattem is a tions, and superclasses are generalizations. When functionality subclass of pattern. is factored into hierarchies, classes are more reusable and main- Inheritance can also be used in a more pragmatic fashion, tainable. Highly factored hierarchies are also easier to extend. in which a class is placed in a hierarchy because of the desire to inherit code and implementation rather than behavior, In- HEURISTICS heritance used in this fashion is called implementation inbi- A significant part of creating subclasses is choosing the most tance. Most class libraries also have examples of this kind of appropriate superclass. It is almost always better to inherit be- inheritance: Processis a subclass of OrderedColleciion,and Debug- havior rather than reimplement behavior, though not at the ger is a subclass of ~spector. cost of inheriting inappropriate behavior. In order to inherit the greatest amount of appropriate behavior, we use two BUSROUTE EXAMPLE heuristics to select candidate superclasses. An example involving bus routes will illustrate the different kinds of inheritance. In this example, we need to create a HEURISTIC ONE class to represent a bus route, which is used to inform the Look for a class that fits the “is a kind of” or “is a type of” rela- bus driver and passengers of the bus’ path through the city. tionship with your new subclass. Often it helps to make this A bus route is a collection of bus stops, in a particular order. heuristic into an English question. For example, we can ask A bus route needs the ability to compose the route out of the question, “IS a pyramid a kind of solid?” bus stops, to supply a summary report on the route’s stops, to Documentation describing a class often helps you under- determine how many intermediate stops there are between stand exactly what the class represents. Because of your un- two stops, and the fare from one stop to another. The fare derstanding of classes that you implemented, it is much easier computation may vary depending on which zones the stops to insert new classes into hierarchies that you have devel- are located in. oped, Personal knowledge of the class hierarchy can substi- People who are familiar with Smalltalk class libraries will tute for class documentation. immediately start to think of the class OrderedCollefion when they read the description of a bus route. OrderedCollection is a HEURISTICTWO concrete collection class that holds elements in order, similar Look for a class with behavior that is similar to the desired be- to a stack or queue. The elements can be of any type. 21. VOL. 1, No. 9: JULYIAUGUST1992 ■ GEUING REAL

BEHAVIORAL INHERITANCE ALTERNATIVE Another alternative is to make BusRoutea subclass of some Ordered other class. A bus route is a kind of route. Are there any route Collection classes in the Smalltalk library? If the answer is no, then make BusRoutea subclass of Object.The behavior csfObjectis appropri- ate for all objects, so Objectis selected when there isn’t any other appropriate superclass. This alternative is an example of behavioral inheritance because all the behavior in Objectis ap- propriate for BusRoute.The inheritance relationship is shown in Figure 2. ‘7 In this akernative, BusRoutewould collaborate with Ordered- BusRoute Collefion to store bus stops in order. Figure 3 illustrates the collaboration between the two objects. An instance variable, n busStops, references an instance of OrderedColleclionthat stores bus stops. Instances of BusRoute can relay messages to the in- Figure l. BusRouk asasubclsss or OrderedCoUection, stance of OrderedCollection referenced by the busStops instance variable. IMPLEMENTATION INHERITANCE ALTERNATIVE We need to make a new class, which we will call BusRoute. OVERRIDE INAPPROPRIATE METHODS Should BusRoutebe a subclass of OrderedCollecbon?As a subclass In the first alternative, in which BusRoutewas a subclass of Or- of OrderedColletion,it would inherit the implementation that deredCollection,we proposed using inherited public methods maintains elements in order. It would also inherit the code for such as add: and remove: to compose the bus route. But this is adding and removing elements which can be used to compose not a very good way to compose bus routes because bus the bus route, This relationship is shown in Figure 1. mutes would be subject to accidental and inappmpriwe It is useful to determine whether this placement of Bus- modifications. Further, if a bus stop is added to a route, then Routeuses behavioral inheritance or implementation inheri- what results is a new and different route. h should not be the tance. Is a bus route a kind of ordered collection? No. In- same object. stances of OrderedCollectionhave an implicit responsibility to Many methods must be overridden to disallow in-place hold objects of arbitrary type, and a bus route holds only bus modifications. For example, the add: method is public and stops. A BusRouteis not a generic data structure class. should be overridden to prevent changes. Is all the behavior of OrderedCollectionappropriate for Bus- BusRoutesubchss of OrderedColleti”on Route?No. According to the description, bus routes shouldn’t respond to the do:, seleti or reject messages, or many of the instancemethods other generic collection messages. Therefore, BusRouteis not a add tiusstop subtype of OrderedCollection.Placing BusRouteas a subclass of Or- “OverrideinheritedpubLicmethod to produce sn error. deredColletion is an example of implementation inheritance, in Bus stops cannot be added to a route.” which code and implementation are usefully inherited. ‘self error ‘Busroutes cannotbe modified.’

In the second alternative, in which BusRoute is a subclass of Object,we don’t need extra methods to override inappropriate behavior. Object

CREATE NEW BUSROUTES A more appropriate way to compose bus routes disallows in. place modifications. We need to make an instance creation

BusRoute FH=l

Figure 2. BusRoute as a subclsss of ObjecL Figure 3. BusRoutecollaborates with OrderedCoUeciinn. 22.

THE SMALLTALKREPORT method that creates an initialized bus route. To support the instance creation method, a private instance method is ziPPY OLject Oriented Database needed to set the collection of bus stops. Management System BusRoutesrsbcfassof Object Obiect Tk ONLY ODBMS for Smalldls for under $10(M dsd dnlivem Pereidenf classmethods O&ITLd ob-~sf.rq..nDbkfi.Zppy B+T- DAsase Rebieml Es@ne! wfthAlk colleeliOnOfSusStops “Createa new in.stnce ofthe receiverinitialized M emery - ~ierarchiod ~mM from ,” ApplicationsD ‘self newbusStops: colleclionOfBuaStops k SmdlfJWV ~ andsIMlldk-ao ~isnited (6U) s37-2117 instance methods ~ PLtformn $199.95 12407- ~~ N., Suih #lCSM66 So- Crde Lcludrd kin, TX 7S76S busstop~ collecUonOfSueStops “Private- Set the collefion of bus stops.” mantics, in which no duplicates are allowed. Another could buaStops := colledionOfSusStops support sorted collection semantics, Each subclass can be implemented by simply overriding the initialization method. This is much more awkward with implementation Classes that collaborate with BusRouteneed to accas the inheritance. bus stops to select stops based on some criteria. The class Bus- In the behavioral inheritance alternative, the exact col- Routeneeds to provide access to the bus stops and protect the laboration between BusRoute and OrderedCollection is clear be- private collection of bus stops from modification. The in- cause messages are relayed to the instance of OrderedCollec- stance method busStopsreturns a copy of the collection refer- tion from BusRoute. In the implementation inheritance enced by the instance variable. This way collaborators can alternative, there is no collaboration. An examination of modify the returned collection of bus stops without any side BusRoute does not determine which methods from OrderedCol- effec~ on the bus route. [efion are used by BusRoute. Instead, collaborators of Bus- Route must be examined. Furthermore, because not all in- Brssitautesubclassof Object herited messages are appropriate, other developers will not instancemethods know which messages they can send to BusRoute. This makes bssestops it much more difficult to extend and maintain the applica- “Returna copyof the collection of bus stops.” tion containing BusRoute, and to reuse BusRoute in related applications, *busStops COPY

SUMMARY New bus routes can be created using these methods. The Use behavioral inheritrmce whenever possible, because the re- following code illustrates the creation of a new route based on sulting subclasses will be more reusable and easier to maintain. the bus stops from another route: In locating subclasses in a hierarchy, use the is-kind-of criteria and similar behaviors to guide your selection. Only after locat- shoppingStops := downtownRoutebusStops. ing a subclass based on behavior should you examine imple- shoppingStops removeFirst. derivedRoute :=BusRoutewithAILshoppingstops mentation details. It is okay to change the superclass. After some implemen- tation and testing, it is quite common to revisit class place- REUSE LMPACTS ment in the hierarchy, Reexamining placement can occur in One of the benefits of the behavioral inheritance alterna- conjunction with reorganizing the entire hierarchy and with tive is that it is easy to change the collection characteris- the addition of new classes, ❑ tics. It is easier to modify the initialization code that allo- cates an object for an instance variable than to rearrange the hierarchy in order to get different collection character- ]uanita Ewing is a setior staffmember of Dig-itdk Professional Services istics. If you are forced to rearrange the hierarchy, then col- (fonnm[y Insuntiatiom Inc.). She has been a project leader for several laborators of BusRoutemust change also. This is because dif- commercial object-orientedsoftware projects, and is an expert in the ferent collection classes respond to different messages, and design and irnpkrz.entation of object-oriented applications, frmnewmks, the inherited messages are directly accessed by the collabo- and systems. h a previous position at Tektronix Inc., she was respon- rators of BusRoute, sible for the deuel.oprnentof theelms librariesfor thejirst commercial- Also, new subclasses of BusRoutecan be created based on qzudity Smakd.k-80 system. Her professionalactivitiesinclude Work- collection characters tics. One subclass could support set se- shop and Panel Chairs for theannual ACM 00PSLA conference. -)2 LJ .

VOL. 1, No. 9: JJLYIAUGUST1992 AB REPORT JustinO. Graver

Smalltalk researchat the University of Florida

recognized need for separate name spaces within a single Smalltalk image. Our application modules provide user- Reports of current work in Smalltalk defined statically scoped name spaces. This permits enforce- taking place in leading university and able private classes and the specification of well-defined research laboratories. module interfaces. We also plan to implement statically en- forceable private methods. The ultimate goal of the module system is to support modules with statically typed public in- terfaces. These typed interfaces would allow each module to he main focus of Smalltalk research at the University be independently compiled and optimized, using the TS of Florida is to demonstrate the viability of evolution- (Typed Smalltalk) compiler. We have designed and proto- T ary prototyping as an alternative to the traditional wa- type a typed module compiler. Given type declarations for terfall model of software development, Specifically, we are only public interface messages and primitives, the module working on a variety of enhancements to the Smalltalk pro- compiler statically determines all intermediate type informa- gram development environment (PDE). These include new tion necessary to compile and partially optimize the module change management tools and techniques, application mod- (further optimization can be performed when different mod- ules, and a string-to-object translator generator. We are also ules are linked together). The module compiler uses a tech- working on the more abstract tasks of understanding, formaliz- nique called abstract interpretation to trace the effects and ing, and validating evolutionary prototyping as a new software requirements of each public interface message. This tech- development methodology. nique also handles arbitrarily recursive methods. To provide Smalltalk was originally designed as a programming envi- better support for both TS and the module compiler, and to ronment for a single user. As Smalltrdk moves slowly into the fuel additional research into object-oriented compiler re- arena of large-scale industrial software applications produced search, we have designed and implemented a string-to-object by tens (or hundreds) of programmers, the need for more pow- translator generator tool called T-gen. T-gen provides a erful change management and versioning capabilities is appar- comprehensive set of translator generator options including ent. The change management tools project is addressing this EBNF grammar specification, fully automatic keyword detec- need in a variety of ways. As a prelude to using a commercial tion, tracing and consistency checking, LL and LR parser database for source code management, we have broken up generation, support for automatic generation of parse trees, Smalltalk’s monolithic source code file into several smaller and automatic generation of T–gen- independent scanner module files. We’ve built tools for creating, loading, version- and parser classes. ing, and maintaining large code libraries of module files. A Smalltalk parser (to be used as the new TS front end) These tools automatically determine the complex dependen- is just one of the projects that has been successfully built us- cies that exist between library modules so that modules get ing T-gen. We have also used T-gen to implement a com- loaded in the correct sequence. We have also chosen to exper- piler for an instructional language called Tiny. Tiny has iment with the class as the smallest unit of versioned granular- been used for over five years in the graduate and undergradu- ity (all change management tools available for Smalltalk ate compiler courses at the University of Florida. We hope PDEs that we know of use individual methods as the lowest to use the new Smalltalk implementation of Tiny to further level of granularity). Since large Smalltalk applications easily instill object-oriented principles into the CIS curriculum. grow to include hundreds of classes with tens of thousands of These research projects have been primarily funded by the methods, we felt that classes might provide a more convenient Software Engineering Research Center (SERC). SERC is an and manageable level of granularity. NSF sponsored Industry/University Cooperative Research Closely coupled with the change management improve- Center. Researchers from Arizona State University, Purdue ?.4 ments is the notion of application modules. There is a widely University, and the University of Florida are working jointly /4. THESMALLTALKREPORT fii. ;o’lltaIk/Vuseed~ke;o&. l?.t . . p

0Put related classes and methods into a single task- orientedobjectcalled application. with over a dozen major companies to solve current prob- “ Bnzwse what the application sees, yet easily move code lems in software engineering. For more information about Mxveen it and external environment. SERC contact Tammera Reedy by phone at 904.392.1520, 0Automatically document code via moditlable templates. 0 Keep a historyof previous versions; restore them with or by e.mail at tct+%fl.edu. Much of this research is an out- a few keystrokes. growth of the ongoing Typed Smalltalk project at the Uni- e View class hiemrchy as graph or list. versity of Illinois at Urbana-Champaign. We maintain ac- 0Print applications, classes, and methods in a formatted tive collaboration with that team, which is lead by Ralph report, aginated and commented. Johnson. This successful interaction has been greatly facili- 0File cOSfe into applications and merge them together. tated by the sharing of tools developed at both institutions. 0Applications are unaffected by compress log change and tni3tly0th121 features.. T-gen runs under ParcPlace’s Objectworks/Smalltalk Release ...... class 4 and is available via anonymous ftp from the University of ‘ Deleted classes ! Illinois Smalltalk Archives (st.cs.uiuc.edu) in the directory Browsers.. rAppficatiq—... ~...... ❑ <“”---”””””---”--”-””””””””””-”-”-”’ /pub/st80_r4/T-gen2,0. Yarn :....Deleted...... methods...... :. [mager

Product Announcements are not reviews. They m-ealmrac~d from press releasesprovided by vendors, and no endorsement is implied. Vendors interested in beinginc[uded in thisfeature shouldsend press releases to our editorial ojjices, Product Announcements Dept., 91 Second Ave. ,Otmwa, Ontario K] S 2H4, Canada.

SynergisticSolutions Inc. has announced additional platform support Servio Corp. and Hewleti-Packard Co. announced that Servio has for SmallteltdSQ~ the porrable database interface for Smalltalk. The been named an HP Value-Added Business Partner and that Servio’s product works in conjunction wirh the latest releases of ParcPlace Sys- object database and GeODE object development en- tems’ ObjeccworksKmalltalk and Digftalk SmalkalkfV. The product enables vironment will be made available for the HP Apollo 9000 Series 700 development of graphical user interthce (GUI) applications which access PA-RISC-baaed workstation family in the third quqrter of 1992.

information stored in relational databases. GemStone is the only ODBMS to SUppOK applications writren in C, SmalltalklSQL provides direct Sybase connectivity for Windows 3.0, C++, and Smalltalk GemStone’s Object Development Environment, Macintosh, Sun, RS/6000 and other UNIX platforms. Direct Omcle sup- GeODE, is zhe first code-free development environment for visually and port is currently available for Windows 3.0 and Sun SPARCsrations. Gupta w@cdb designingand building ODBMS applications. and NetwareSQL support is available for the Windows 3.0 and 0S/2. For more brfarmatlors, contact Servio Corp., 950 Marina Village Parkway, For mom hs~rnsaflon, contact SyssergfstlcSokrrhrs Inc. 63 ]opsw’ Dr. Suite 110, Alameda, CA 94501, 510.#14,6200. Lawrencevllle,NJOM4#, 60W#&O025. VC Software Construction has announced enhancements to their ob- ject-oriented darsbase management system, ODBMS. The package sup- Logic Arta announces VOSS/Personal,twolow-cost versions of the Vir- ports most Smallralk languages. ILSsrorage ticilicies of objects can be used tual Object Stotage System for Smalkalk/V 2S6 and Smalkalk/V Windows. during the development of Smalldk applications as well as by a standalone VOSS/Personal is tidly compatible with the equivalent main producr database application. ODBMS stores items in opposition co relational line, and can read and write the same virutsl object spaces, providing databases’ arbitrary complex data sypes. There is almost no Iimization to transparent access to persistent Smalltalk objects of any class on disk, the structure and length of these items. without rhe need for a separate DBMS programming language. k has the ODBMS/SQL uses the optimized query algorithms of SQL to retrieve =me mansaction management of updates, the variable-size cache of virtual objects faster. The intention of the access to relational databases into objects in the image, and most of the same VirtualDictionary and Virtual ODBMS avoids redundancy in stored items and enhances the use of Collection classes for managing collections larger than the image. Smalltcdk in rhe commercial environment.

For mm-e Information, contact Logic Arts Ltd, 75 Hemh@wd Rd, Cambridge, For more hsformathr, contact: VC Software Corrrtruction, Petritorwd 28, England. CBI 3BY, +44 223212392, fax +44 223245171. 3300 f2rounschwel& Gwnsany, +49 S3 I 242400, fax +4953 12424024. 25. VOL. 1, No. 9: ]ULYIAUGUST1992 Excerpts from industry publications

WORDS OF WISDOM or imagined, the elements that must combine to make multimedia ...Can you say objem-oriented ?.. .How about real-time systems, graphi- a reality are coming together. And “the ambitions of diverse busi- cal environment=, multimedia, or CASE technology? If you want to get nesses competing and cooperating in the convergence of telecom- laid off, don’t mention or learn these topics. Even better, tell anyone munications, computing and TV,” as Englander puts it, guarantee who will listen shat object-oriented development is only a t%d... that the ride will be an interesting one.

Eleven ways to get laid OK Karen Hooten, COMPUTER LANGUAGE 3/92 En mute to cdabamtk camputing, Samuel Weber, ELECTRONICS, 4/92

SMALLTALK CREATIVE IMPLEMENTATION ., ,You must realize that I use a variety of languages in my work ...If no one knows what is going on inside an object’s functions, C++, Smallmlk, and Adar in particular. I use Smallsalk for prototyp- and no one can romper with its dam without authorization, rhen an ing, and here, ics dynamic binding allows me to throw together pro- object is highly secure. k polices its own borders, responding only to totypes quickly, with blatint disregard for any kind of type of safety authorized messages.. .Since an object has boundaries, you can own it or robustness. For the kind of experimental development I do, this You can reward or punish the persons who designed it. You can rent is precisely the kind of flexibili~ I need . . . out the use of the object without telling how it works. You can see a Interview with Grady Beach, THE C++ JOURNAL vd2/no. /, 1992 certain appeal here to the corpomte mind . . . Object-orientedpmgrammin~ wisat’sthe big deal?, Birrell Walsh, STRATEGIES MICROTIMES, 3192 ...00P-basedsoftware will presem courts with challenging questions concerning, among other things, infringement and risk allocation. As . . .I’ve discovered that the single grexest challenge of mckling a new the courts wrestle with these issues, suppliers, developers, and users object-oriented program is keeping a vision of the program that’s must be careful that agreements with one another address, to the ex- accomplishable. As I was writing this progtam, I have to admit that at tent possible, their specific rights and duties in this changing area. times I was thinking of an interactive CD-ROM-based multi-media ex- travaganza. Luckily, common sense and deadlines prevailed . . . Making sure that 00P doesn’t become oops, Rabert V. l-lawn, BUSINESS JOURNAL SERVING SANJOSE AND THE SILICON VALLEY, 31i6192 Expert’s toolbox templates of doom, Larry OBrien, THE CHICAGO PURCHASER, 5192 MULTIMEDIA SimGraphics Engineering Corp, is changing the face of animation. Us- TOOLS AND LIBRARIES ing a powerful graphics workstation, a face armature, an object- ., ,There’s much more to realizing the benefit of a class Iibm-y than oriented toolkit, and one of the world’s most famous software game simply buying one at random and throwing it at a development prob characters, the company is ushering in the day when r=l-time anima- Iem (or team). There are three geneml problems that can make it tion will largely replace frame-by-frame animation. “Obviously, you al- difficult to make good use of cles libraries. First, since you’re ex- ways will be able WI get higher resolution from frame-by-ftame anima- pected to derive new classes, what’s to prevent you from creating a tion, but there will be a point when both software and hardware will mess?.. .A second problem occurs when you try to incorporate a class permit most of the animation that now is being done frame by frame Iibtary into an existing application. You may have an optimal applica- to be done in real time,” says Steve Glenn, vice president of New tion, but the library designer had a unique purpose in mind co create Business Development for SimGraphics of South Pasadena, CA... the optimal library design. Are the two designs compatible?.. .Finally, The many (ices afMaria, Margaret Seabom, WORKSTATION NEWS, 5/92 diflerent vendors may have d“fiering ideas about optimal library de- sign.There isn’t really any such thing as a standard for class . . .Object-oriented progtams already exisr for imaging, though they libraries.. .All these problems have one ttait in common: inconsistency. aren’t well publicized. This is unfortunate, as object-oriented pre None of the problems are really the fault of class libraries per se; it’s gtamming will affect the growth of digital photography more than really the way we create and use them along with our own under- anything else,.. standing of the proper approach to object-oriented progtam develop- Digital photography:changingfor the better, john Larish, ment that determines whether class Iibtaries are a major benefit... PHOTO ELECTRONIC IMAGING, 4192 Development tools,Mike Stewa~ COMPUTER SHOPPER, 3192

. . .For multimedia computing, all the Dataquest survey respondents . . .In the tlkure, access to object Iibtaries may determine which devel- felt there was still a lot to be done in providing application soft- oper (or company) is able to serve clients most adequately. k is ware, increasing network data rates, providing wideband telecom- hoped that the elegance of one’s code, long a measure of the quality munication networks, and finalizing standards. But despite these of one’s produ~ will remain the determinant of success in our indus- unresolved problems, the multimedia juggernaut rolls on. “To try. However, this may be the case only if no one company or class of many, this looks like a tidal wave starting to swell,” says AT&T’s companies is able to dominate the source of sofware objects. In a [Arnold] Englander. Certain elements are in place, he says: the perfect world, there will be a plentiful supply of public domain objecrs readiness of the telecommunications infrastructure; the emer- accessible to everyone, via the same channels from which we are all gence of critical video-compression and telecom standards; ad- now accustomed to getting our sources. vances in image compression, VLSI technology, and object-oriented Concerningyaur career, Jimjohnsan, programming; and the high costs of travel in a business environ- UNIFORUM MONTHLY, 3192 -. ment that’s ever more global in scope. More rapidly than expected ,46. THESMALLTALKREPORT ANALYSIS AND DESIGN ...[Rob Dickerson, VP and Genetal Manager of The Daiabase Busi- Voss ness Unit at Borland International]: 1think you’ve got to learn to do a class hierarchy. The first time you do your class hierarchy, you Virtual Object Storage System for write out what looks obvious, and you fiddle with it, and you realize it’s not the best one. So you redesign it, and by the time you’re Srnalltalk/V done, the class hierarchy you end up with w not what you initially .%2mless persistent object management thought. And there’s a bunch of tricks to it—how to identify a for aU Smalltalk/V applications meta-class, factoring, the notion of collection classes, how to design Transpa~nt ace-s to all Kindsof Smalltalkcrb~s on disk, a class hierarchy, but that’s the main design effoti At leas~ that’s . ● Transaction mmmit/roUback of changes to virtual objects. what I’ve seen our R&D guys have to get their hands around. [Jacob ● Access to individualelementsof virtual mllections for ODBMSup Stein, Chief Technologist for Servio Corp]: And there’s lots of to 4 billionob@ts per virtual space; objectscached for speed. trade-offs, trade-offs between reusabili~, and a natural fit to the sys- ● Multi-key and multi-value virtual dictionaries for query-building tem you’re modeling, They might not always be exactly the same. by key nuqgeselection and set interaction. (rip) There may be a trade-off between designing for reuse and designing ● Works directly with third party user intesface & SQL classes etc. for this particular application, and you have to take that broader ● Cfass Restructure Editor for renaming clas~s and adding or scope. It’s said that people don’t get classes right until they’ve been removing inrtance variables allows appficatiom to evolve. (rip) ● implemented about three times, which might mean that some of the Shared access to named virtual object spaces on disk; object portability between irna~. Virtual objects are fuf2yfunctional, interfaces will change during that course of time . . . ● Source code supplied, Rourrdtabk: experrs speok on object-orienteddevelopment!,JohnLHawkins and Somecommentsw hue reu-ivedaboutVOSS: Dion Sch@hauser, DATA BASED ADVISOR, 4192 “,, ,clean elegant. Works likea charm.” -Hal Ffildebnrnd,Anmvd Ldwatories “Works absolutely beautifully; excellent performance and DISTRIBUTED ENVIRONMENTS applicabilityy.” -Rind Durm, MicrogersicsInstrunsrnts ,.,“Object technology offers a second-generation model for VDS5/2E6$595(Persanal$199), VOSS/ Windows S75U(Personal 5299) client/server, with a clear role for a powerful client as well as a (Persmnal w’siom exclude item nuarked (rip)). [~fl~~ ~&ydismunkkomW% firlwoormo~mpi-( Askfordetails) powerful server,” said David Gilmour, executive vice-president of asterCardandEuroCardaccepted.Pleaseadd$15forshipping. sales and marketing for Versant Object Technology, Menlo Park, ~R T S h“~cAfis Ltd 75 HerningfordRoad,Cambridge,England,CB13BY Calif. By raising the power of an individual object to suppom trans- TEL +44223212352 FAX +44 223245171 parent peer-to-peer communication via messages, the idea of clientlsetwer extends to a more robust notion of objects. Under They are complementary technologies chat when combined, can give this notion, objects could at one point make requests as clients to a company a formidable competitive advantage . . . semers, then at other points act as server to other clients. This al- On tfsefrontendReport card on Enfin/2, Robert C BoftjDBMS, 4192 lows a modular distributed system that maybe more responsive to change. Using objects as the unit to be distributed may allow devel - opers to save implementation issues-such as distribution-until DATABASES after the design is complete. “This is because object technology is ...In the world of textual data, relational databases worked fine. an inherently parallel technology that naturally thrives in a dis- Text gives you structure and form in the way of character strings tributed multiprocessing environment,” said Dr. David Taylor, prin- and numbers. This is something an RDBMS can handle quite well. cipal of Taylor Consulting, San Mateo, Calif... Unfortunately, when you scam dealing with multimedia data types— ObjecIS can set the stage, Etic Aranow and Tom Kehler, where you have to deal with massive amounts of this data, many of SOFTWAREMAGAZINE 5192 them being object-bssed-an RDBMS falls flat. By contrast, object- oriented databases come out way ahead of RDBMSS when dealing ., ,Object-oriented DBMSS combine database technologies and object- with heterogeneous, complex data involved in complex relation- oriented progmmming to provide greater modeling power and flexibiL ships. More importantly, when you start getting applications de- ity to programmers of data intensive applications. Over the last five signed to integrate these multimedia data types into their programs, years, 00 DBMSS have been the subject of intensive research and ex- it will be important for them to include, as a part of the applica- perimentation, which led to an impressive number of prototypes and tions, an object-oriented database to help them handle these new commercial products. But the theory and ptactice of developing dis- types of object based data. At first, you will see these object-based tributed 00 DBMSS have yet to be My developed. Distributed envi- databases added to authoring products, then to presentation, draw- ronments will make the problems even more d-ficult In addition, the ing and desktop-publishing products. They will also become impor- issues of data dictionary management and distributed object manag= tant to any word-processing and next generation on-screen docu- ment have yet to be dealt with. However, distribution is an essential ment communications. Ironically, it will not be the traditional requiremen~ since applications that require 00DBMS technology typ database suppliers that will help these independent software ven- ically arise in nemvorked workstation environments.. .However, dis- dors use a database effectively in this multimedia-driven world. tributing an object-oriented datsbase within a network of worksrations Even though they all have object-based databases in the works, un- (and servers) is becoming very attractive. In f%cL some 00DBMSS al- less they are able to perfect them soon and make them work har- ready support some form of data distribution transparency... moniously with their RDBMS programs of today, rhey could be left Diw”buted dototrosesystems where were we?, M. Tamer Ozsu and Patrick out in the cold. In the future, the database will be embedded in ma- Vakiuriez, DATA BASE PROGRAMMING& DESIGN, 4192 jor applications so they can manipulate these stored images, video and sound and integrate them into the heart of the app. Whether As if the jump to a client/server information system patadigm were anyone likes it or not, multimedia computing is going to revolution- not tough enough, many companies are looking at moving to o~ect- ize the way we use computers. oriented programming (OOP) as well. By my measure, the 00 mar- The sofl view: multimedia simply spells a new digital data type, Tim Bojorin, ket today is about where the clientk.ewer market was three to four COMPUTER RESELLER NEWS, 4120192 years ago, and the two are even stinting to merge in some areas. 27,

VOL. 1, No. 9: JULY/AUGUST1992 KEYmms ■ W6rld’sleading, awadwinning object- oriented programming system 1 Complete protoqpe-to-deliie~ system ■ Zero-cost runtime ■ Simplified application delivery for creating standalone executable (.EXE) applications ■ Code portabili~ between SmalItalk/V Windows and Smalltalk/V PM ■ Wrappers for all Windows and 0S/2 WNDOWSAND0s/2: controls W Support for new CUA ~1 controls for 0S/2, including drag rinddrop, booktab, conrainti, value set, slider and more PRm EN)DELIVERYH Tmspamnt support for Dynamic Data Exchange (DDE) and Dynamic Link Library (DLL) calls ■ Fully integrated programming environ- NowmGo ment, including interactive debuggeq source code browsem (all source code h Windows and 0S/2, you need prototypes. you have to get a sense included), world’s most extensive Win- for what an application is going to look like, and feel like, before you can write dows and 0S/2 class libraries, tutorial it. And you can’t afford to throw the prototype away when you’re done. (printd and on disk), extensive samples With Smalltalk/V you don’t. H Extensive dmeloper support, including Start with the prototype. There’s no development system you can buy techniml support, training, electronic that lets you get a working model working faster than SmalltalkN developer forums, free user newsletter ■ Then, incrementally, grow the prototype into a finished applica- Bread base of tlird-party support, including add-on Small@ products, tion. Tky out new ideas, Get input from your U.WE.,Make morr changes. consulting services, books, user groups Be creative. Smalltalk/V gives you the freedom to experiment without risk. It’s made for trial, And error. You make changes, and test them, one at a time. Safely. You get immediate feedback when you make a change. And you can’t make changes that bnmk the system. It’s that safe. And when you’re done, whether you’re writing applications for Windows or 0S/2, you’ll have a standalone application that runs on both. Smalhalk/V code is portable between the Windows and the 0S/2 versions. And the resulting application carries no runtime charges. All for just $499.95. So take a look at This SmalltsW Windowsapplication SmaUtalk/V today. It’s time to make ~@u~d the PC WeekShootout ad —md that prototyping time productive. SmalltalklvIt wascompletedin 6 hours.

Smalltalk/V is a registered trademark ofDigiAk,Inc.Other product names a-s trademark or registered trademarks of their respective holders. D~italk, Inc., 9841 AirpJrt Blvd., L.nsAngeles, CA 90045 (S00) 922-8255; (213) 64>-1OEI2; Fax (213) 645-1306

LOOK WHO’S TALKING HEWLETT-PACKARD NCR HP bm devslopedanetwork troubl.- NCR baJ an integrated iest program deueiop- sbooiing tool cal.lsdh Network Advisoz men.t environment for digikzljLVZUIOFand The Network Advixor offer~ a compreben- mtied mode pn”nted circuit board ts~ting five wt of tooh including an sxpert ~yxtem, skziirtics, and firotocol decodes to xpeed MIDLAND BANK pvoblem i.rohtion. The NA user inf-srface i.r Midksnd Bank buiit a Windowed Xscbnicd SmafItslk/V PM applications am used to buitt on a windowing xyxtem which .Iiows Tmding En.irvnment jor curmnq futum~ develop state-of-theart CUA-compliant and stock tmders using Snza[ltiIk Y multiple application to be sxecuted applimtions — and they’re ~rtsbk to ~imuIt4ms0usIy. Smalldk/V Windows.