Programming Examples with a Software Engineering Perspective
1 Tiny.Tiny Examples of Spec/Design
- ./Dutch-National-Flag Correct by Design example by Dijkstra.
- ./Quick-Sort Why is it hard to understand and then remember?
- ./SmallSet A simple implementation of a set of integers. Shows
pre/post and class invariants.
- ./Condense-Num-Ranges E.g., given 2 - 9 and 3 -12, condense to
2 - 12. Spec and design.
- ./Magic-Squares Construct n x n matrix of numbers so that columns,
rows and diagonals add up to the same number.
- ./Tabulate-Equations such as a collection from algebra. Spec and design.
- ./Telegram-Problem The problem of Peter Naur. Famous people wrote
buggy solutions!
- ./Worms wiggly worms, some vegetarian, others cannibals. Presented
as (i) a software "maintenance" problem, and (ii) as an example of
writing assertions.
- ./TicTacToe-JavaFX-UnRedo Presented as a software "maintenance"
problem. Is it bug free?
- ./Game-Of-Life Conway's GoL. Presented as a software "maintenance"
problem. TBD Incomplete.
- ./Columnize-Words Part of /bin/ls spec.
- ./Mark-Error-Pos A required method within a compiler. Position an
arrow, and next to it print error numbers.
2 JavaCard
- JavaCard is a subset of Java chosen for small memory, weak-CPU, embedded
devices. Widely used in SIM cards and ATM cards.
- Read further at ./Java-Card
3 Knuth's Common Words Problem
- "Given a file of text, and a number k, print the k most common words."
- Knuth's example of Literate Programming
- Our interest here: How to describe its spec + design?
- 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.
- Read further at ./Knuth-CWP
4 Knuth, Donald E. "TEX: The Program"
- Knuth, Donald E. "TEX: The Program", Volume B of Computers and
typesetting. (1986). 624 pages, Addison-Wesley Professional;
ISBN-10: 0201134373
- An example of Literate Programming.
- 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
- 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."
- Read further at ./Pretty-Printer Spec + Design.
6 A Programmers' Editor
- Editors suitable for developing code.
- Read further at ./Editor
8 References
- Others and Bertrand Meyer, "How Specifications Change and Why You
Should Care" PDF Jan 2013. Required Reading.
- 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.
Copyright © 2015 •
www.wright.edu/~pmateti • 2015-06-15