Story Test Driven Development

Total Page:16

File Type:pdf, Size:1020Kb

Story Test Driven Development Test and Measure DON’T JUST BREAK How storytest- SOFTWARE.driven development is MAKE changing the SOFTWARE.way QA, customers, STORYTEST-DRIVEN DEVELOPMENT (STDD) IS AN EXTREME PROGRAMMING PRACTICE. and The basic premise is that before developers any code is written, a team takes work. a story (or rough idea of a require- by Tracy Reppert ment) and fleshes out that story by producing an executable “story- test.” Opponents say that STDD is “cowboy coding,” or “snake oil,” or 18 BETTER SOFTWARE JULY/AUGUST 2004 www.stickyminds.com MACK/REDUXPRESTON PLUS STDD rates high with the development team at Nielsen Media Research. Standing (l to r): Thomas Hund, Praseed Thapparambil, and Pam Smoot. Seated (l to r): Cheryl Redding, Rhoda Foxworthy, and Merrilee Albright Test and Measure specific contract for acceptance, so dis- crepancies are quickly resolved. There’s a “Creating the expected results clear context for customers and develop- was quite challenging, but it ers to have a conversation and weed out was rewarding when they ran.” misunderstandings. The risk of building —MERRILEE ALBRIGHT the wrong system is much lower.” Ken Auer, president of RoleModel Software and one of the earliest practi- just “a hindrance to real work.” Propo- expectation of the customer into an exe- tioners of STDD, agrees. His team, along nents argue that STDD produces the sim- cutable and readable contract that pro- with Ward Cunningham, first used plest system possible and is the wave of grammers have to obey if they want to STDD to produce a software system in the future, the new frontier. claim a working system. 1999. “STDD made it easier to nail “STDD gets the right people collabo- down what our end-users wanted,” re- EVERYONE GETS A SAY rating at the right time,” says Joshua calls Auer. “By having executable re- With traditional acceptance testing, de- Kerievsky, XP coach and founder of In- quirements for each story, we were able velopers would create an entire system, dustrial Logic, Inc. STDD brings together to know when we had completed stories, declare it finished, and then submit it for the customer, developers, and testers be- which made project tracking a whole lot acceptance testing. This mostly manual fore any code has been written. They col- easier and better.” testing tended to get bogged down in pa- laborate to identify a specific piece of perwork and occurred so late in the de- functionality, or “story,” to be worked NO ONE HAS TO BE velopment lifecycle that any mistakes on. Customers and testers then specify THE BAD GUY were very expensive to fix. Even if the criteria to validate that the story works Raha explains that not only does STDD system met all of the stated requirements and create an executable document that relieve stress; all the involved parties love and passed through acceptance testing can be accessed by anyone on the team. the process. “Customers love it because with flying colors, the customer, who “When testing is done after the fact, of the new level of confidence they get— hadn’t seen the system since the require- customers simply say that the system is instead of just hoping the development ments meeting, often was left feeling like broken when it doesn’t meet their require- team has understood the requirements he had not gotten what he wanted. ments,” says Somik Raha, XP coach for correctly. Developers love it because STDD makes it possible to formalize the Industrial Logic. “With STDD, there is a there’s no way they can be accused of from being lost in abstract discussions and vague generalities. A GLIMPSE To illustrate, let’s suppose a business has a rule that, for ac- counting purposes, all months are treated as having thirty days. OF STDD (Some bonds are valued under a similar rule.) One of the stories might be “Implement the 30-day rule.” The business expert IN ACTION. might write something like this on the whiteboard: by 1 April to 1 May is 30 (as normal) Brian 1 Feb to 1 March is 30 (even though 28) Marick 1 Jan to 1 Feb is 30 (really 31) QUESTIONS should follow. A programmer or tester might ask if STORYTESTS AS PROPS FOR CONVERSATION it’s really true that the number of days from 1 January to both In order to estimate a story, programmers have to understand 1 February and 31 January is thirty. The business expert would what the business expert wants. They learn this through face- answer that it is. Then someone else might ask, “So, it’s twen- to-face conversation. The business expert describes the feature, ty-seven days from 1 February to 11:59 PM on 28 February, but explains why it’s useful, and gives examples, perhaps scribbling the next minute it’s thirty days?” The business expert might them on a whiteboard. The programmers ask questions, split start to answer “Yes,” only to be interrupted by someone say- the feature into constituent parts (smaller tasks), ask more ing, “Not if it’s a leap year,” which would lead to a discussion questions about those tasks, and sometimes propose variations of the relevance of leap years, and then, perhaps, to whether on the feature that might be simpler to implement. time zones matter. That discussion might well be cut short, because the point EXAMPLES are particularly useful because they ground the con- here is for the programmers to have enough information to es- versation in something concrete and keep important details timate accurately, not for them to know every last detail. 20 BETTER SOFTWARE JULY/AUGUST 2004 www.stickyminds.com Test and Measure building a system that is not acceptable. THE FIRST STEP CAN helps teams obtain the necessary amount And QA loves it because programmers BE A BIG ONE of story details when they need it—before aren’t viewing them as the bad guys,” If STDD is so great, why do so many peo- writing code. says Raha. ple distrust it? Perhaps some of the skep- Even now that most of the quirks STDD challenges the notion that QA tics of STDD haven’t experienced it since have been worked out, people may still has to play a rival role to a programming its inception. XP and STDD definitely had be wary of such a big change. “It was dif- team if they expect to be able to spot de- some growing pains. Joshua Kerievsky ex- ficult to trust the process in the begin- fects. In practice, teams find that they plains, “In the early days of XP, we did a ning,” says Pam Smoot, senior project are saving a lot of time by having QA lot of unit test-driven development and manager at Nielsen Media Research, help produce storytests from the begin- would automate storytests only after we’d which began implementing STDD for a ning. “A tester is sometimes viewed as written our code. The trouble with this major data-warehousing project, “but it’s an adversary, when all they are trying to approach was that it was often hard to get so much better than what we used to do. do is ensure that the delivered product subject matter experts to define storytests, Having expected results created upfront functions well,” says Merrilee Albright, lead SQA analyst at Nielsen Media Re- search and member of an STDD team. “It was difficult to trust “I’ve been testing a long time, and have the process in the beginning, found that my role on this team definite- but it’s so much better than ly has more respect than it might in the normal software development process. I what we used to do.” —PAM SMOOT can utilize the expertise of other team members to help me create tests. Having the customer available to review the test which meant that with successive itera- by a business/QA person helped us find results and make suggestions immediate- tions we would get further and further be- miscalculations, misinterpretations, and ly has proved invaluable. Creating the hind on the number of storytests we still miscommunications right away rather expected results was quite challenging, needed. That produced higher defects, than late in the project.” but it was rewarding when they ran and since the lack of sufficient story details led Skeptics begin to see the value of ensured that the system was functioning to code that failed to fully satisfy customer STDD in just a couple of weeks, accord- as expected.” expectations.” He adds that STDD now ing to Smoot, though it can take a few CONVERSATIONAL EXAMPLES getting those tests to pass, other people can contin- BECOME STORYTESTS ue writing tests. The test-driven style is to make tests Once the iteration is planned, it’s the job of the programmers pass one at a time; while working on one test, the continued to produce features that satisfy the business expert, and it’s programmer doesn’t worry overmuch about what > the job of the business expert to support them—mainly by be- tests remain. So it doesn’t matter if some of those ing available for further conversation. For example, a program- tests are not yet known. These storytests do not necessarily mer might realize that she doesn’t know what the program completely replace conventional testing. They’re designed to should do in some special case, so the business expert has to build quality into the product. Someone else still needs to cre- tell her. Or a programmer might realize that the code is so ate tests to detect where the storytests fell short of the goal structured that it would be trivial to add a new wrinkle to the of preventing bugs.
Recommended publications
  • Patterns Senior Member of Technical Staff and Pattern Languages Knowledge Systems Corp
    Kyle Brown An Introduction to Patterns Senior Member of Technical Staff and Pattern Languages Knowledge Systems Corp. 4001 Weston Parkway CSC591O Cary, North Carolina 27513-2303 April 7-9, 1997 919-481-4000 Raleigh, NC [email protected] http://www.ksccary.com Copyright (C) 1996, Kyle Brown, Bobby Woolf, and 1 2 Knowledge Systems Corp. All rights reserved. Overview Bobby Woolf Senior Member of Technical Staff O Patterns Knowledge Systems Corp. O Software Patterns 4001 Weston Parkway O Design Patterns Cary, North Carolina 27513-2303 O Architectural Patterns 919-481-4000 O Pattern Catalogs [email protected] O Pattern Languages http://www.ksccary.com 3 4 Patterns -- Why? Patterns -- Why? !@#$ O Learning software development is hard » Lots of new concepts O Must be some way to » Hard to distinguish good communicate better ideas from bad ones » Allow us to concentrate O Languages and on the problem frameworks are very O Patterns can provide the complex answer » Too much to explain » Much of their structure is incidental to our problem 5 6 Patterns -- What? Patterns -- Parts O Patterns are made up of four main parts O What is a pattern? » Title -- the name of the pattern » A solution to a problem in a context » Problem -- a statement of what the pattern solves » A structured way of representing design » Context -- a discussion of the constraints and information in prose and diagrams forces on the problem »A way of communicating design information from an expert to a novice » Solution -- a description of how to solve the problem » Generative:
    [Show full text]
  • Wiki As Pattern Language
    Wiki as Pattern Language Ward Cunningham Cunningham and Cunningham, Inc.1 Sustasis Foundation Portland, Oregon Michael W. Mehaffy Faculty of Architecture Delft University of Technology2 Sustasis Foundation Portland, Oregon Abstract We describe the origin of wiki technology, which has become widely influential, and its relationship to the development of pattern languages in software. We show here how the relationship is deeper than previously understood, opening up the possibility of expanded capability for wikis, including a new generation of “federated” wiki. [NOTE TO REVIEWERS: This paper is part first-person history and part theory. The history is given by one of the participants, an original developer of wiki and co-developer of pattern language. The theory points toward future potential of pattern language within a federated, peer-to-peer framework.] 1. Introduction Wiki is today widely established as a kind of website that allows users to quickly and easily share, modify and improve information collaboratively (Leuf and Cunningham, 2001). It is described on Wikipedia – perhaps its best known example – as “a website which allows its users to add, modify, or delete its content via a web browser usually using a simplified markup language or a rich-text editor” (Wikipedia, 2013). Wiki is so well established, in fact, that a Google search engine result for the term displays approximately 1.25 billion page “hits”, or pages on the World Wide Web that include this term somewhere within their text (Google, 2013a). Along with this growth, the definition of what constitutes a “wiki” has broadened since its introduction in 1995. Consider the example of WikiLeaks, where editable content would defeat the purpose of the site.
    [Show full text]
  • Project1: Build a Small Scanner/Parser
    Project1: Build A Small Scanner/Parser Introducing Lex, Yacc, and POET cs5363 1 Project1: Building A Scanner/Parser Parse a subset of the C language Support two types of atomic values: int float Support one type of compound values: arrays Support a basic set of language concepts Variable declarations (int, float, and array variables) Expressions (arithmetic and boolean operations) Statements (assignments, conditionals, and loops) You can choose a different but equivalent language Need to make your own test cases Options of implementation (links available at class web site) Manual in C/C++/Java (or whatever other lang.) Lex and Yacc (together with C/C++) POET: a scripting compiler writing language Or any other approach you choose --- must document how to download/use any tools involved cs5363 2 This is just starting… There will be two other sub-projects Type checking Check the types of expressions in the input program Optimization/analysis/translation Do something with the input code, output the result The starting project is important because it determines which language you can use for the other projects Lex+Yacc ===> can work only with C/C++ POET ==> work with POET Manual ==> stick to whatever language you pick This class: introduce Lex/Yacc/POET to you cs5363 3 Using Lex to build scanners lex.yy.c MyLex.l lex/flex lex.yy.c a.out gcc/cc Input stream a.out tokens Write a lex specification Save it in a file (MyLex.l) Compile the lex specification file by invoking lex/flex lex MyLex.l A lex.yy.c file is generated
    [Show full text]
  • GNU M4, Version 1.4.7 a Powerful Macro Processor Edition 1.4.7, 23 September 2006
    GNU M4, version 1.4.7 A powerful macro processor Edition 1.4.7, 23 September 2006 by Ren´eSeindal This manual is for GNU M4 (version 1.4.7, 23 September 2006), a package containing an implementation of the m4 macro language. Copyright c 1989, 1990, 1991, 1992, 1993, 1994, 2004, 2005, 2006 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License.” i Table of Contents 1 Introduction and preliminaries ................ 3 1.1 Introduction to m4 ............................................. 3 1.2 Historical references ............................................ 3 1.3 Invoking m4 .................................................... 4 1.4 Problems and bugs ............................................. 8 1.5 Using this manual .............................................. 8 2 Lexical and syntactic conventions ............ 11 2.1 Macro names ................................................. 11 2.2 Quoting input to m4........................................... 11 2.3 Comments in m4 input ........................................ 11 2.4 Other kinds of input tokens ................................... 12 2.5 How m4 copies input to output ................................ 12 3 How to invoke macros........................
    [Show full text]
  • GNU M4, Version 1.4.19 a Powerful Macro Processor Edition 1.4.19, 28 May 2021
    GNU M4, version 1.4.19 A powerful macro processor Edition 1.4.19, 28 May 2021 by Ren´eSeindal, Fran¸coisPinard, Gary V. Vaughan, and Eric Blake ([email protected]) This manual (28 May 2021) is for GNU M4 (version 1.4.19), a package containing an implementation of the m4 macro language. Copyright c 1989{1994, 2004{2014, 2016{2017, 2020{2021 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled \GNU Free Documentation License." i Table of Contents 1 Introduction and preliminaries ::::::::::::::::: 3 1.1 Introduction to m4 :::::::::::::::::::::::::::::::::::::::::::::: 3 1.2 Historical references :::::::::::::::::::::::::::::::::::::::::::: 3 1.3 Problems and bugs ::::::::::::::::::::::::::::::::::::::::::::: 4 1.4 Using this manual :::::::::::::::::::::::::::::::::::::::::::::: 5 2 Invoking m4::::::::::::::::::::::::::::::::::::::: 7 2.1 Command line options for operation modes ::::::::::::::::::::: 7 2.2 Command line options for preprocessor features ::::::::::::::::: 8 2.3 Command line options for limits control ::::::::::::::::::::::: 10 2.4 Command line options for frozen state ::::::::::::::::::::::::: 11 2.5 Command line options for debugging :::::::::::::::::::::::::: 11 2.6 Specifying input files on the command line :::::::::::::::::::::
    [Show full text]
  • Analysis Patterns.Pdf
    Symbols for mappings DLKING , : www.dlking.com Generalization notation DLKING , : www.dlking.com Contents Foreword v Foreword vii Preface xv Chapter 1. Introduction 1 1.1 Conceptual Models 1 1.2 The World of Patterns 4 1.3 The Patterns in this Book 8 1.4 Conceptual Models and Business Process Reengineering 10 1.5 Patterns and Frameworks 11 1.6 Using the Patterns 11 References 14 Part 1. Analysis Patterns 15 Chapter 2. Accountability 17 2.1 Party 18 2.2 Organization Hierarchies 19 2.3 Organization Structure 21 2.4 Accountability 22 2.5 Accountability Knowledge Level 24 2.6 Party Type Generalizations 27 2.7 Hierarchic Accountability 28 2.8 Operating Scopes 30 2.9 Post 32 References 33 Chapter 3. Observations and Measurements 35 3.1 Quantity 36 3.2 Conversion Ratio 38 3.3 Compound Units 39 3.4 Measurement 41 3.5 Observation 42 3.6 Subtyping Observation Concepts 46 3.7 Protocol 46 3.8 Dual Time Record 47 IX DLKING , : www.dlking.com x Contents 3.9 Rejected Observation 48 3.10 Active Observation, Hypothesis, and Projection 49 3.11 Associated Observation 50 3.12 Process of Observation 51 References 55 Chapter 4. Observations for Corporate Finance 57 4.1 Enterprise Segment 59 4.2 Measurement Protocol 65 4.3 Range 76 4.4 Phenomenon with Range 77 4.5 Using the Resulting Framework 82 References 83 Chapter 5. Referring to Objects 85 5.1 Name 86 5.2 Identification Scheme 88 5.3 Object Merge 90 5.4 Object Equivalence 92 References 93 Chapter 6.
    [Show full text]
  • Software Development Lifecycle (Sdlc) Models & Agile Methods
    sdlc% how did that happen? software development lifecycle (sdlc) models & agile methods • by analogy with civil engineering, where you design first, then do construction • in software, there is no “construction” it’s all design • used to be called coding sdlc%(2)% sdlc%(3)% • what is a software development process? • what is the lifecycle of a software project? • will talk about “agile” later. first, we’ll talk about “disciplined” or is it “traditional?” or is it “sturdy?” or is it “planned?” or is it… sdlc%(4)% example%feature%workflow% • tend to talk about sdlc in terms of a dichotomy – !“agile”!vs.!well…um…“not!agile”! – or,!“planned”!vs.!“con8nuous”! – others!tend!to!(incorrectly)!think!that!the! deployment!method!implies!the!process! • saas!==!agile! • installed!==!tradi8onal! • think more in terms applying the process on an individual feature, or an aggregate goal%of%sdlc% waterfall% Requirements! Design! Construc8on! • what’s the goal of a good sdlc? Integra8on! – passes!all!the!tests!(external!quality!aAriButes)! Debugging! – good!design/architecture!(internal)! Installa8on! Maintenance! – good!user!experience!(quality!in!use)! • move from one phase to the next only when its preceding phase is – process!quality!(can!process!help!ensure! completed and perfected. product!quality)! • first mentioned by Royce in 1970 as an example of a flawed, non- working model for software development. • US department of defence projects attempted to entrench this model by requiring their contractors to produce the waterfall deliverables and then to formally accept them to a certain schedule (US military standard DoD-2167) – there!was!a!unwieldy!process!for!going!Back!and!amending!previous! deliverables! waterfall%(2)% waterfall%(3)% more problems problems • static view of requirements – ignores volatility • lack of user involvement once specification is written • unrealistic separation of specification from design • often tracked with Gantt charts! • doesn’t easily accommodate prototyping, – printed!and!taped!up!on!the!wall! reuse, etc.
    [Show full text]
  • An AWK to C++ Translator
    An AWK to C++ Translator Brian W. Kernighan Bell Laboratories Murray Hill, NJ 07974 [email protected] ABSTRACT This paper describes an experiment to produce an AWK to C++ translator and an AWK class definition and supporting library. The intent is to generate efficient and read- able C++, so that the generated code will run faster than interpreted AWK and can also be modified and extended where an AWK program could not be. The AWK class and library can also be used independently of the translator to access AWK facilities from C++ pro- grams. 1. Introduction An AWK program [1] is a sequence of pattern-action statements: pattern { action } pattern { action } ... A pattern is a regular expression, numeric expression, string expression, or combination of these; an action is executable code similar to C. The operation of an AWK program is for each input line for each pattern if the pattern matches the input line do the action Variables in an AWK program contain string or numeric values or both according to context; there are built- in variables for useful values such as the input filename and record number. Operators work on strings or numbers, coercing the types of their operands as necessary. Arrays have arbitrary subscripts (‘‘associative arrays’’). Input is read and input lines are split into fields, called $1, $2, etc. Control flow statements are like those of C: if-else, while, for, do. There are user-defined and built-in functions for arithmetic, string, regular expression pattern-matching, and input and output to/from arbitrary files and processes.
    [Show full text]
  • Pedagogical and Elementary Patterns Patterns Overview
    Pedagogical and Elementary Patterns Overview Patterns Joe Bergin Pace University http://csis.pace.edu/~bergin Thanks to Eugene Wallingford for some material here. Jim (Cope) Coplien also gave advice in the design. 11/26/00 1 11/26/00 2 Patterns--What they DO Where Patterns Came From • Capture Expert Practice • Christopher Alexander --A Pattern Language • Communicate Expertise to Others – Architecture • Solve Common Recurring Problems • Structural Relationships that recur in good spaces • Ward Cunningham, Kent Beck (oopsla ‘87), • Vocabulary of Solutions. Dick Gabriel, Jim Coplien, and others • Bring a set of forces/constraints into • Johnson, Gamma, Helm, and Vlisides (GOF) equilibrium • Structural Relationships that recur in good programs • Work with other patterns 11/26/00 3 11/26/00 4 Patterns Branch Out Patterns--What they ARE • Software Design Patterns (GOF...) •A Thing • Organizational Patterns (XP, SCRUM...) • A Description of a Thing • Telecommunication Patterns (Hub…) • A Description of how to Create the Thing • Pedagogical Patterns •A Solution of a Recurring Problem in a • Elementary Patterns Context – Unfortunately this “definition” is only useful if you already know what patterns are 11/26/00 5 11/26/00 6 Patterns--What they ARE (2) Elements of a Pattern • Structural relationships between •Problem components of a system that brings into • Context equilibrium a set of demands on the system •Forces • A way to generate complex (emergent) •Solution behavior from simple rules • Examples of Use (several) • A way to make the world a better place for humans -- not just developers or teachers... • Consequences and Resulting Context 11/26/00 7 11/26/00 8 Exercise Exercise • Problem: Build a stairway up a castle tower • Problem: Design the intersection of two or • Context: 12th Century Denmark.
    [Show full text]
  • Make a Jump Start Together with Software Ag
    Software AG Fast Startup FAST STARTUP PROGRAM MAKE A JUMP START TOGETHER WITH SOFTWARE AG You have great ideas, a clear vision and the drive to build something really cool. You are smart, you are fast, you are innovative and you are determined to become a rock star of the startup community. Need some free software to build your solution on? Here’s the secret. When it comes to software partnership, the key differentiators are: technology leadership, ease of use, total cost of ownership and—most importantly—reliability. Why Software AG? Why not just freeware? The key to your success is a brilliant business idea, a sustainable For a homegrown, non-mission-critical application, there is business model, openhanded investors and finally paying nothing wrong with choosing freeware. But if you need best-in- customers. class functionality and reliability to build your business on, you It’s a strong partnership that can be the differentiator in the should think twice about the software you use. success of your business. What is your innovation? What do you require as the foundation That’s why you should partner with Software AG. for your intellectual property? Why should you spend time re- Building on 45 years of customer-centric innovation, we are inventing what professional developers invented and optimized ranked as a leader in key market categories, year after year. Our over many years for their paying customers? Do you want to grow solutions are faster to implement and easier to use than anything your business or just your development team? How reliable are else on the market.
    [Show full text]
  • Frontiers of Pattern Language Technology
    Frontiers of Pattern Language Technology Pattern Language, 1977 Network of Relationships “We need a web way of thinking.” - Jane Jacobs Herbert Simon, 1962 “The Architecture of Complexity” - nearly decomposable hierarchies (with “panarchic” connections - Holling) Christopher Alexander, 1964-5 “A city is not a tree” – its “overlaps” create clusters, or “patterns,” that can be manipulated more easily (related to Object-Oriented Programming) The surprising existing benefits of Pattern Language technology.... * “Design patterns” used as a widespread computer programming system (Mac OS, iPhone, most games, etc.) * Wiki invented by Ward Cunningham as a direct outgrowth * Direct lineage to Agile, Scrum, Extreme Programming * Pattern languages used in many other fields …. So why have they not been more infuential in the built environment??? Why have pattern languages not been more infuential in the built environment?.... * Theory 1: “Architects are just weird!” (Preference for “starchitecure,” extravagant objects, etc.) * Theory 2: The original book is too “proprietary,” not “open source” enough for extensive development and refinement * Theory 3: The software people, especially, used key strategies to make pattern languages far more useful, leading to an explosion of useful new tools and approaches …. So what can we learn from them??? * Portland, OR. Based NGO with international network of researchers * Executive director is Michael Mehaffy, student and long-time colleague of Christopher Alexander, inter-disciplinary collaborator in philosophy, sciences, public affairs, business and economics, architecture, planning * Board member is Ward Cunningham, one of the pioneers of pattern languages in software, Agile, Scrum etc., and inventor of wiki * Other board members are architects, financial experts, former students of Alexander Custom “Project Pattern Languages” (in conventional paper format) Custom “Project Pattern Languages” create the elements of a “generative code” (e.g.
    [Show full text]
  • The Cool Reference Manual∗
    The Cool Reference Manual∗ Contents 1 Introduction 3 2 Getting Started 3 3 Classes 4 3.1 Features . 4 3.2 Inheritance . 5 4 Types 6 4.1 SELF TYPE ........................................... 6 4.2 Type Checking . 7 5 Attributes 8 5.1 Void................................................ 8 6 Methods 8 7 Expressions 9 7.1 Constants . 9 7.2 Identifiers . 9 7.3 Assignment . 9 7.4 Dispatch . 10 7.5 Conditionals . 10 7.6 Loops . 11 7.7 Blocks . 11 7.8 Let . 11 7.9 Case . 12 7.10 New . 12 7.11 Isvoid . 12 7.12 Arithmetic and Comparison Operations . 13 ∗Copyright c 1995-2000 by Alex Aiken. All rights reserved. 1 8 Basic Classes 13 8.1 Object . 13 8.2 IO ................................................. 13 8.3 Int................................................. 14 8.4 String . 14 8.5 Bool . 14 9 Main Class 14 10 Lexical Structure 14 10.1 Integers, Identifiers, and Special Notation . 15 10.2 Strings . 15 10.3 Comments . 15 10.4 Keywords . 15 10.5 White Space . 15 11 Cool Syntax 17 11.1 Precedence . 17 12 Type Rules 17 12.1 Type Environments . 17 12.2 Type Checking Rules . 18 13 Operational Semantics 22 13.1 Environment and the Store . 22 13.2 Syntax for Cool Objects . 24 13.3 Class definitions . 24 13.4 Operational Rules . 25 14 Acknowledgements 30 2 1 Introduction This manual describes the programming language Cool: the Classroom Object-Oriented Language. Cool is a small language that can be implemented with reasonable effort in a one semester course. Still, Cool retains many of the features of modern programming languages including objects, static typing, and automatic memory management.
    [Show full text]