PART VI: Appendices

Total Page:16

File Type:pdf, Size:1020Kb

PART VI: Appendices PART VI: Appendices This part complements the main material of the book by providing an introduction to four important programming languages: Java, C#, C++ and (briefly) C. The presentations are specifically designed for the readers of this book: they do not describe the four languages from scratch, but assume you are familiar with the concepts developed in the preceding chapters, and emphasize the differences with the Eiffel notation that they use. The descriptions do not cover the languages in their entirety, but include enough to enable you to start programming in these languages if you have mastered the concepts of the rest of this book. For practical use of a language system (compiler, interpreter, integrated development environment) you will of course need the corresponding reference information, from books or online. Since not every reader will want to learn every one of the languages, each of the first three appendices can be read independently; this also means, since Java, C# and C++ share a number of characteristics (due to the influence of C and, for the first two, C++), that if you do read all three you will encounter some repetitions. The fourth appendix is a short overview of C presented as a subset of C++, and hence assumes that you have read the C++ appendix. The last appendix presents basic information about using the EiffelStudio environment, to help with the examples of this book and the Traffic software. The appendices are followed by the list of picture credits and the index. A An introduction to Java (from material by Marco Piccioni) A.1 LANGUAGE BACKGROUND AND STYLE Java was introduced in 1995, the result of an internal research project at Sun Microsystems led by James Gosling (other key contributors include Bill Joy, Guy Steele and Gilad Bracha). The language came at just the right time to benefit from two separate phenomena: • Widespread dissatisfaction, after initial enthusiasm for object technology in the late eighties, with the C++ language (see appendix C), particularly its complexity and the limits of its “hybrid” approach retaining compatibility with the non-object-oriented C language. • The spread of Internet access and the advent of the World-Wide Web, Gosling (2007) which seemed to call for a universal mechanism to execute programs securely from within browsers. The Java project, initially intended for “set-top boxes” and network appliances, was ready to support such programs, called applets. As noted in an earlier chapter, ← “Virtual machines, applets never became the dominant computing model as prophesied at the time, bytecode and jitting”, page 333. but Java usage quickly expanded to many other application areas. The following properties characterize the Java programming model: • A close connection between the programming language and a computing platform based on a virtual machine, called a JVM (Java Virtual Machine). • An emphasis on portability captured by the slogan “Write Once, Run Anywhere” and based on compilation to the JVM’s bytecode, which can then be interpreted, or compiled to machine code, on many platforms. • Syntax, general language style and basic instructions taken from the C-C++ line of languages. • A strongly typed object-oriented model, with many of the mechanisms studied in this book: classes, inheritance, polymorphism, dynamic binding, genericity (added in recent versions). Some missing elements are multiple inheritance (except for “interfaces”, as we will see), contracts and agents; in addition, the O-O part of the type system does not include primitive types. • Beyond the language proper, a rich set of libraries supporting software development in many application areas. B. Meyer, Touch of Class: Learning to Program Well with Objects and Contracts, 747 DOI 10.1007/978-3-540-92145-5, © Springer-Verlag Berlin Heidelberg 2013 748 AN INTRODUCTION TO JAVA (FROM MATERIAL BY MARCO PICCIONI) §A.2 A.2 OVERALL PROGRAM STRUCTURE We first review the general structure of a Java program, starting with an overview of the Java Virtual Machine. The Java Virtual Machine A Java Virtual Machine is a software system providing mechanisms to support the execution of Java programs. (We may talk of “the” JVM as the general specification of these mechanisms, and “a” JVM as one particular implementation.) Here are the principal mechanisms: •A class loader manages classes and libraries in the file system and dynamically loads classes in bytecode format. •A verifier checks that bytecode satisfies fundamental constraints on ← “Null” is the same reliability and security: type safety (non-null references always lead to as “void”: see objects of the expected types); information hiding (feature access observes “Void references”, 6.3, page 111. visibility rules); branch validity (branches should always lead to valid locations); initialization (every data element is initialized before use). •An interpreter, the software equivalent of a CPU in a physical computer, executes bytecode. •A Just In Time compiler (JIT compiler or “jitter”) translates bytecode into ← “Virtual machines, machine code for a specific platform, performing various optimizations. bytecode and jitting”, page 333. The most widely used JIT compiler is “Hot Spot” from Sun. Packages Java programs, like those in other object-oriented languages, are structured into classes, but Java offers a modular structure above the class level: the package. A package is a group of classes (like Eiffel “clusters”, which are not a language mechanism but an organizational concept). Packages fulfill three main roles. The first is to help you structure your systems and libraries. Packages can be nested, and hence make it possible to organize classes in a hierarchical structure. This structure is conceptual, not textual; in other words, you will not declare a package as such (with its constituent classes), but instead declare classes and in each of them indicate the name of its package if any: package p; class A {… Declarations of members of A …} class B {… Declarations of members of B …} … Other class declarations … §A.2 OVERALL PROGRAM STRUCTURE 749 If this is the content of a source file, all classes given belong to package p. The package directive, if present, must be the first line in the file. Nested packages use the dot notation: p.q is the sub-package q of p. The package directive is optional; in its absence, all classes in a file will be considered to belong to a special default package. The second role of packages is as compilation units. Rather than compiling classes individually, you can compile an entire package into a single “Java Archive” (JAR) file. In their third role, closely related to the first, packages provide a namespace mechanism to resolve the class name conflicts that may arise when you combine libraries from different providers. When referring to a class A belonging to a package p, you may always use the fully qualified name: p.A. This technique also applies to classes from subpackages, as in p.q.r.Z. To avoid full qualification, you may use the import directive: writing import p.q.∗; allows the rest of the file to use the classes from p.q without qualification, as long as this does not create any conflict. (The asterisk ∗ means “all classes from the package”, not including subpackages.) Fully qualified notation remains available to resolve ambiguities. The package mechanism comes with some methodological recommendations. One recommendation is to use it in its explicit form: include every class in a named package (in other words, do not rely on the default package). Another follows from the observation that packages and namespaces only push the name clash problem one step, since you can still have clashes between package names. To minimize the likelihood that this will happen, a standard convention for packages uses names that start with the institution’s Internet domain, listing components in reverse order; for example a package originating with the Chair of Software Engineering at ETH Zurich (our group, domain name se.ethz.ch) might be called ch.ethz.se.java.webtools.gui Program execution From a command line, the command to start the execution of a Java program is: java C arg1 arg2 … 750 AN INTRODUCTION TO JAVA (FROM MATERIAL BY MARCO PICCIONI) §A.3 where C is the name of a class and the optional arguments arg1 arg2 … are strings. The effect is to execute a method (routine), which must be present in C under the name main: public static void main(String[] args) { … Code for main program… } Unlike in Eiffel, this does not create an object since a “static” method (as ← “System execution”, explained below) does not need an object. Of course main will usually create 6.8, page 130. objects, or call other methods that create objects. The optional formal argument →“Static members”, is an array of strings (String[]), corresponding in the above call to arg1 arg2 … page 753. The public qualifier, also studied below, makes main available to all clients. A.3 BASIC OBJECT-ORIENTED MODEL We now take a look at the basic object-oriented mechanisms of Java; the discussion assumes familiarity with the concepts of the preceding chapters. The Java type system Most Java programmer-defined types will, as in most examples of this book, be reference types, each based on a class. At the top of the class hierarchy stands a class called Object (think of ANY, but there is no equivalent to NONE). ← “Overall inheritance structure”, A major difference with the type system assumed in the rest of this book 16.10, page 586. affects basic types. In Eiffel, and in C# as studied in the next appendix, every type is based on a class; this includes basic types describing arithmetic, boolean and character values. Java, in contrast, follows C++ in treating a number of basic types as predefined outside of the object-oriented type system.
Recommended publications
  • Declarative Immutability in Java
    International Journal of Computer and Systems Engineering Volume 1 Issue 1 Article 4 July 2020 Declarative Immutability in Java John Crowley Boston College, University of Pennsylvania, [email protected] Follow this and additional works at: https://digitalcommons.fairfield.edu/ijcase Recommended Citation Crowley, John (2020) "Declarative Immutability in Java," International Journal of Computer and Systems Engineering: Vol. 1 : Iss. 1 , Article 4. Available at: https://digitalcommons.fairfield.edu/ijcase/vol1/iss1/4 This item has been accepted for inclusion in DigitalCommons@Fairfield by an authorized administrator of DigitalCommons@Fairfield. It is brought to you by DigitalCommons@Fairfield with permission from the rights- holder(s) and is protected by copyright and/or related rights. You are free to use this item in any way that is permitted by the copyright and related rights legislation that applies to your use. For other uses, you need to obtain permission from the rights-holder(s) directly, unless additional rights are indicated by a Creative Commons license in the record and/or on the work itself. For more information, please contact [email protected]. Declarative Immutability in Java Online at https://digitalcommons.fairfield.edu/ijcase/ Published by Fairfield University, DigitalCommons@Fairfield © 2020 Vol. 1, No. 1, 2020 Declarative Immutability in Java by John D. Crowley ABSTRACT A pervasive mechanism is proposed to declare that variables and object instances are mutable or immutable, and whether methods mutate instances. These declarations are integral to the type structure of the language and allow the developer to declare, and the reader (and compiler) to determine, if a variable or instance is immutable (even if other instances of the Class are mutable) or that an instance is immutable throughout the application (a Pure instance).
    [Show full text]
  • Scala for the Impatient Second Edition This Page Intentionally Left Blank Scala for the Impatient Second Edition
    Scala for the Impatient Second Edition This page intentionally left blank Scala for the Impatient Second Edition Cay S. Horstmann Boston • Columbus • Indianapolis • New York • San Francisco • Amsterdam • Cape Town Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at [email protected] or (800) 382–3419. For government sales inquiries, please contact [email protected]. For questions about sales outside the United States, please contact [email protected]. Visit us on the Web: informit.com/aw Library of Congress Control Number: 2016954825 Copyright © 2017 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise.
    [Show full text]
  • The Pragmatic Programmer Your Journey to Mastery
    Extracted from: The Pragmatic Programmer your journey to mastery 20th Anniversary Edition Boston • Columbus • New York • San Francisco • Amsterdam • Cape Town Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo The Pragmatic Programmer your journey to mastery 20th Anniversary Edition Dave Thomas Andy Hunt Boston • Columbus • New York • San Francisco • Amsterdam • Cape Town Dubai • London • Madrid • Milan • Munich • Paris • Montreal • Toronto • Delhi • Mexico City São Paulo • Sydney • Hong Kong • Seoul • Singapore • Taipei • Tokyo Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. "The Pragmatic Programmer" and the linking g device are trademarks of The Pragmatic Programmers, LLC. The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at [email protected] or (800) 382-3419. For government sales inquiries, please contact [email protected]. For questions about sales outside the U.S., please contact [email protected].
    [Show full text]
  • Study on Eiffel
    Study on Eiffel Jie Yao Anurag Katiyar May 11, 2008 Abstract This report gives an introduction to Eiffel, an object oriented language. The objective of the report is to draw the attention of the reader to the salient features of Eiffel. The report explains some of these features in brief along with language syntax. The report includes some code snippets that were written in the process of learning Eiffel. Some of the more detailed tutorials, books and papers on Eiffel can be found at www.eiffel.com 1 Contents 1 Introduction 3 2 Eiffel Constructs and Grammar 3 2.1 ”Hello World” . 3 2.2 Data Types . 3 2.3 Classes . 3 2.4 Libraries . 4 2.5 Features . 4 2.6 Class relations and hierarchy . 4 2.7 Inheritance . 4 2.8 Genericity . 5 2.9 Object Creation . 5 2.10 Exceptions . 6 2.11 Agents and Iteration . 6 2.12 Tuples . 6 2.13 Typing . 6 2.14 Scope . 7 2.15 Memory Management . 7 2.16 External software . 7 3 Fundamental Properties 7 3.1 ”Has” Properties . 8 3.2 ”Has no” Properties . 9 4 Design principles in Eiffel 10 4.1 Design by Contract . 10 4.2 Command Query Separation . 11 4.3 Uniform Access Principle . 11 4.4 Single Choice Principle . 11 5 Compilation Process in Eiffel 11 6 Exception Handling in the compiler 12 7 Garbage Collection for Eiffel 12 7.1 Garbage Collector Structure . 12 7.2 Garbage Collector in Action . 13 8 Eiffel’s approach to typing 13 8.1 Multiple inheritance .
    [Show full text]
  • PML2: Integrated Program Verification in ML
    PML2: Integrated Program Verification in ML Rodolphe Lepigre LAMA, CNRS, Université Savoie Mont Blanc, France and Inria, LSV, CNRS, Université Paris-Saclay, France [email protected] https://orcid.org/0000-0002-2849-5338 Abstract We present the PML2 language, which provides a uniform environment for programming, and for proving properties of programs in an ML-like setting. The language is Curry-style and call-by-value, it provides a control operator (interpreted in terms of classical logic), it supports general recursion and a very general form of (implicit, non-coercive) subtyping. In the system, equational properties of programs are expressed using two new type formers, and they are proved by constructing terminating programs. Although proofs rely heavily on equational reasoning, equalities are exclusively managed by the type-checker. This means that the user only has to choose which equality to use, and not where to use it, as is usually done in mathematical proofs. In the system, writing proofs mostly amounts to applying lemmas (possibly recursive function calls), and to perform case analyses (pattern matchings). 2012 ACM Subject Classification Software and its engineering → Software verification Keywords and phrases program verification, classical logic, ML-like language, termination check- ing, Curry-style quantification, implicit subtyping Digital Object Identifier 10.4230/LIPIcs.TYPES.2017.5 1 Introduction: joining programming and proving In the last thirty years, significant progress has been made in the application of type theory to computer languages. The Curry-Howard correspondence, which links the type systems of functional programming languages to mathematical logic, has been explored in two main directions.
    [Show full text]
  • Software Quality / Modularity
    Software quality EXTERNAL AND INTERNAL FACTORS External quality factors are properties such as speed or ease of use, whose presence or absence in a software product may be detected by its users. Other qualities applicable to a software product, such as being modular, or readable, are internal factors, perceptible only to computer professionals who have access to the actual software text. In the end, only external factors matter, but the key to achieving these external factors is in the internal ones: for the users to enjoy the visible qualities, the designers and implementers must have applied internal techniques that will ensure the hidden qualities. EXTERNAL FACTORS Correctness: The ability of software products to perform their tasks, as defined by their specification. Correctness is the prime quality. If a system does not do what it is supposed to do, everything else about it — whether it is fast, has a nice user interface¼ — matters little. But this is easier said than done. Even the first step to correctness is already difficult: we must be able to specify the system requirements in a precise form, by itself quite a challenging task. Robustness: The ability of software systems to react appropriately to abnormal conditions. Robustness complements correctness. Correctness addresses the behavior of a system in cases covered by its specification; robustness characterizes what happens outside of that specification. There will always be cases that the specification does not explicitly address. The role of the robustness requirement is to make sure that if such cases do arise, the system does not cause catastrophic events; it should produce appropriate error messages, terminate its execution cleanly, or enter a so-called “graceful degradation” mode.
    [Show full text]
  • Polymorphic Identifiers: Uniform Resource Access in Objective-Smalltalk
    Polymorphic Identifiers: Uniform Resource Access in Objective-Smalltalk Marcel Weiher Robert Hirschfeld Hasso Plattner Institute, University of Potsdam Hasso Plattner Institute, University of Potsdam [email protected] [email protected] Abstract compose these identifiers, use them on the LHS and RHS and In object-oriented programming, polymorphic dispatch of opera- partially use them for indirect access. Computational abstraction tions decouples clients from specific providers of services and al- is handled separately. lows implementations to be modified or substituted without affect- Object-oriented programming languages such as Smalltalk, ing clients. Java and Objective-C mostly maintain the distinction between The Uniform Access Principle (UAP) tries to extend these qual- computational and storage abstraction, with polymorphism and ities to resource access by demanding that access to state be indis- most other abstraction mechanisms only applying to computational tinguishable from access to operations. Despite language features abstraction. Access to storage, when not mediated via a method, supporting the UAP, the overall goal of substitutability has not been defeats encapsulation and makes code brittle against changes or achieved for either alternative resources such as keyed storage, files subclassing, which is why convention moved toward having all or web pages, or for alternate access mechanisms: specific kinds of access to state (instance variables) mediated by methods. resources are bound to specific access mechanisms and vice versa. The Uniform Access Principle (UAP) [22] was coined by Meyer Changing storage or access patterns either requires changes to both to formalize this convention: access to state should be indistin- clients and service providers and trying to maintain the UAP im- guishable from computation.
    [Show full text]
  • Best Practices in Software Development: Principles of Good
    Best Practices in Software Development: Principles of Good Design Ansgar Fehnker Based on slides by: Arend Rensink, Christoph Bockisch, Mira Mezini, Lodewijk Bergmans What is Good Software? . External criteria . Correctness, robustness, extensibility, efficiency, ease of use ... Stakeholders: . end user, e.g., a travel agent using a flight reservation system . persons who purchase the software, e.g., an airline executive acquiring or commissioning flight reservation systems . Internal criteria . Modularity, readability, reusability, ... Stakeholders: . IT professionals with access to the source . Only external factors matter in the end . but the key to achieving them is in the internal ones Patterns of Software Development 2 External vs. Internal Criteria Patterns of Software Development 3 External Criteria: Correctness . What is correctness? . the ability of a software product to perform its task . as defined by its specification . Examples of (in-)correct systems? Application . Due to complexity, methods for ensuring correctness will usually be conditional or layered . each layer relying on lower ones Hardware Patterns of Software Development 4 External Criteria: Robustness . What is robustness? . the ability of software to react appropriately to abnormal conditions . Examples of (non-)robust systems? . Difference robustness/correctness? . Correctness addresses the behavior of a system in cases covered by its specification . Robustness characterizes what happens outside of that specification Patterns of Software Development 5 External Criteria: Efficiency . What is efficiency? . place as few demands as possible on hardware resources: . processor time, memory, bandwidth, power . Examples of (in-)efficient systems? . A software case of split personality . Mr. Microsecond: shows an exaggerated concern for micro- optimisation. “Premature optimization is the root of all evil” .
    [Show full text]
  • From Eiffel to the Java Virtual Machine
    From Eiffel to the Java Virtual Machine Adding a new language target to the EiffelStudio compiler Søren Engel, [email protected] Supervisor Dr. Joseph R. Kiniry Thesis submitted to The IT University of Copenhagen for the degree of Bachelor of Science in Software Development August 2012 Abstract Previous attemps has been made towards translating and executing programs written in Eiffel on the Java platform, as described in Baumgartner [1]. However, the generated Java code has not been easy to use in terms of interoperability between the two languages, due to the restrictions of the Java language. Due to the evolution of the Java language, the work presented in this thesis examines whether it is possible to simplify the translation model of Eiffel to Java. In doing so, this thesis describes a refined translation model that leverages on some of the new features of the Java language, such as the invokedynamic bytecode instruction. Moreover, in order to verify the correctness of the proposed translation model, a description follows on how the translation model may be integrated into the existing EiffelStudio compiler, in terms extending the back-end to target the Java platform. In regards of simplicity, it was found that by using new language features of Java, the translation model of Eiffel to Java could be simplified to the extend that it solves the known issues found in the solution presented in Baumgartner [1]. In trying to integrate the translation model into the existing EiffelStudio compiler, it was found that no public documentation exists which described the internal structure of the EiffelStudio compiler.
    [Show full text]
  • A Survey on Teaching and Learning Recursive Programming
    Informatics in Education, 2014, Vol. 13, No. 1, 87–119 87 © 2014 Vilnius University A Survey on Teaching and Learning Recursive Programming Christian RINDERKNECHT Department of Programming Languages and Compilers, Eötvös Loránd University Budapest, Hungary E-mail: [email protected] Received: July 2013 Abstract. We survey the literature about the teaching and learning of recursive programming. After a short history of the advent of recursion in programming languages and its adoption by programmers, we present curricular approaches to recursion, including a review of textbooks and some programming methodology, as well as the functional and imperative paradigms and the distinction between control flow vs. data flow. We follow the researchers in stating the problem with base cases, noting the similarity with induction in mathematics, making concrete analogies for recursion, using games, visualizations, animations, multimedia environments, intelligent tutor- ing systems and visual programming. We cover the usage in schools of the Logo programming language and the associated theoretical didactics, including a brief overview of the constructivist and constructionist theories of learning; we also sketch the learners’ mental models which have been identified so far, and non-classical remedial strategies, such as kinesthesis and syntonicity. We append an extensive and carefully collated bibliography, which we hope will facilitate new research. Key words: computer science education, didactics of programming, recursion, tail recursion, em- bedded recursion, iteration, loop, mental models. Foreword In this article, we survey how practitioners and educators have been teaching recursion, both as a concept and a programming technique, and how pupils have been learning it. After a brief historical account, we opt for a thematic presentation with cross-references, and we append an extensive bibliography which was very carefully collated.
    [Show full text]
  • Eiffelstudio: a Guided Tour
    EiffelStudio: A Guided Tour Interactive Software Engineering 2 EIFFELSTUDIO: A GUIDED TOUR § Manual identification Title: EiffelStudio: A Guided Tour, ISE Technical Report TR-EI-68/GT. (Replaces TR-EI-38/EB.) Publication history First published 1993 as First Steps with EiffelBench (TR-EI-38/EB) and revised as a chapter of Eiffel: The Environment (TR-EI- 39/IE), also available as An Object-Oriented Environment (Prentice Hall, 1994, ISBN 0-13-245-507-2. Version 3.3.8, 1995. Version 4.1, 1997 This version: July 2001. Corresponds to release 5.0 of the ISE Eiffel environment. Author Bertrand Meyer. Software credits Emmanuel Stapf, Arnaud Pichery, Xavier Rousselot, Raphael Simon; Étienne Amodeo, Jérôme Bou Aziz, Vincent Brendel, Gauthier Brillaud, Paul Colin de Verdière, Jocelyn Fiat, Pascal Freund, Savrak Sar, Patrick Schönbach, Zoran Simic, Jacques Sireude, Tanit Talbi, Emmanuel Texier, Guillaume Wong-So; EiffelVision 2: Leila Ait-Kaci, Sylvain Baron, Sami Kallio, Ian King, Sam O’Connor, Julian Rogers. See also acknowledgments for earlier versions in Eiffel: The Environment (TR-EI-39/IE) Non-ISE: special thanks to Thomas Beale, Éric Bezault, Paul Cohen, Paul-Georges Crismer, Michael Gacsaly, Dave Hollenberg, Mark Howard, Randy John, Eirik Mangseth, Glenn Maughan, Jacques Silberstein. Cover design Rich Ayling. Copyright notice and proprietary information Copyright © Interactive Software Engineering Inc. (ISE), 2001. May not be reproduced in any form (including electronic storage) without the written permission of ISE. “Eiffel Power” and the Eiffel Power logo are trademarks of ISE. All uses of the product documented here are subject to the terms and conditions of the ISE Eiffel user license.
    [Show full text]
  • Spest - a Tool for Specification-Based Testing
    SPEST - A TOOL FOR SPECIFICATION-BASED TESTING A Thesis presented to the Faculty of California Polytechnic State University, San Luis Obispo In Partial Fulfillment of the Requirements for the Degree Master of Science in Computer Science by Corrigan Johnson January 2016 !c 2016 Corrigan Johnson ALL RIGHTS RESERVED ii COMMITTEE MEMBERSHIP TITLE: SPEST - A Tool for Specification-Based Testing AUTHOR: Corrigan Johnson DATE SUBMITTED: January 2016 COMMITTEE CHAIR: Gene Fisher, Ph.D. Professor of Computer Science COMMITTEE MEMBER: David Janzen, Ph.D. Professor of Computer Science COMMITTEE MEMBER: John Clements, Ph.D. Associate Professor of Computer Science iii ABSTRACT SPEST - A Tool for Specification-Based Testing Corrigan Johnson This thesis presents a tool for SPEcification based teSTing (SPEST). SPEST is designed to use well known practices for automated black-box testing to reduce the burden of testing on developers. The tool uses a simple formal specification language to generate highly-readable unit tests that embody best practices for thorough software testing. Because the specification language used to generate the assertions about the code can be compiled, it can also be used to ensure that documentation describing the code is maintained during development and refactoring. The utility and effectiveness of SPEST were validated through several experiments conducted with students in undergraduate software engineering classes. The first experiment compared the understand- ability and efficiency of SPEST generated tests against student written tests based on the Java Modeling Language (JML)[25] specifications. JML is a widely used language for behavior program specification. A second experiment evaluated readability through a survey comparing SPEST generated tests against tests written by well established software developers.
    [Show full text]