UP | HOME
../../ 2015-06-15

Programming Examples with a Software Engineering Perspective

Table of Contents

1 Tiny.Tiny Examples of Spec/Design

  1. ./Dutch-National-Flag Correct by Design example by Dijkstra.
  2. ./Quick-Sort Why is it hard to understand and then remember?
  3. ./SmallSet A simple implementation of a set of integers. Shows pre/post and class invariants.
  4. ./Condense-Num-Ranges E.g., given 2 - 9 and 3 -12, condense to 2 - 12. Spec and design.
  5. ./Magic-Squares Construct n x n matrix of numbers so that columns, rows and diagonals add up to the same number.
  6. ./Tabulate-Equations such as a collection from algebra. Spec and design.
  7. ./Telegram-Problem The problem of Peter Naur. Famous people wrote buggy solutions!
  8. ./Worms wiggly worms, some vegetarian, others cannibals. Presented as (i) a software "maintenance" problem, and (ii) as an example of writing assertions.
  9. ./TicTacToe-JavaFX-UnRedo Presented as a software "maintenance" problem. Is it bug free?
  10. ./Game-Of-Life Conway's GoL. Presented as a software "maintenance" problem. TBD Incomplete.
  11. ./Columnize-Words Part of /bin/ls spec.
  12. ./Mark-Error-Pos A required method within a compiler. Position an arrow, and next to it print error numbers.

2 JavaCard

  1. JavaCard is a subset of Java chosen for small memory, weak-CPU, embedded devices. Widely used in SIM cards and ATM cards.
  2. Read further at ./Java-Card

3 Knuth's Common Words Problem

  1. "Given a file of text, and a number k, print the k most common words."
  2. Knuth's example of Literate Programming
  3. Our interest here: How to describe its spec + design?
  4. Donald E. Knuth, "A Solution to the Common Words Problem", Communications of the ACM, 1986, search for PDF link. Knuth is a Turing Award winner. Required Reading.
  5. Read further at ./Knuth-CWP

4 Knuth, Donald E. "TEX: The Program"

  1. Knuth, Donald E. "TEX: The Program", Volume B of Computers and typesetting. (1986). 624 pages, Addison-Wesley Professional; ISBN-10: 0201134373
  2. An example of Literate Programming.
  3. One and only one review (last I looked) on Amazon.com: "This book is extremely valuable to those hoping to understand and reuse Knuth's classic typesetting algorithms. It contains every detail needed for the implementation. Each section has a number associated with the source code. Besides, it can also serve as an excellent example of a large project for computer science students. One can understand better "the art of computer programming" after reading this book." Recommended Reading ;-)

5 A Specification Schema For Indenting Programs

  1. http://onlinelibrary.wiley.com/doi/10.1002/spe.4380130206/abstract Abstract: "A two level specification of the functional behaviour of a class of indenting programs for Pascal is presented. The transformation that these programs perform on the input text is a composition of splitting input lines, altering the blank space between lexical tokens and computing the margin required in front of each of the split lines. The high level specification is given as a stylized Pascal grammar in Extended BNF. In contrast, the low level specifications, which are operationally closer to a program, and which define how syntactically invalid text is dealt with, require several mathematical functions that capture the essence of these basic transformations. The specifications of an indenting program for Pascal are then obtained as a further elaboration of these functions. Most indentation styles appearing in the literature can be specified with precision using methods developed in this paper."
  2. Read further at ./Pretty-Printer Spec + Design.

6 A Programmers' Editor

  1. Editors suitable for developing code.
  2. Read further at ./Editor

7 Exercises

  1. Divide Chess-Board-Minus1 into Ls Apparantly an interview question.
  2. Mark Errors A "debugging" problem from Systematic Programming book by Niklaus Wirth. Several "solutions" are presented. Figure out which ones are correct. Preferably use assertions.

8 References

  1. Others and Bertrand Meyer, "How Specifications Change and Why You Should Care" PDF Jan 2013. Required Reading.
  2. Donald E. Knuth, "A Solution to the Common Words Problem", Communications of the ACM, 1986, search for PDF link. Knuth is a Turing Award winner. Required Reading.

9 End


Copyright © 2015 • www.wright.edu/~pmateti • 2015-06-15