Examples written in Squeak/DCI
Squeak is a dialect of Smalltalk. DCI/Squeak is an extension of Squeak to support code written according to the DCI paradigm. BabyIDE is an experimental interactive development environment that supports the DCI paradigm with specialized browsers for its different perspectives. The IDE is described in section 3 in
The Common Sense of Object Oriented Programming.
A ZIP file containing all you need for running Squeak/DCI in Windows XP or 7 can be downloaded from
See its README file for more details.For other operating systems, you need to install Squeak on your computer. Go to http://www-1.squeak.org/ for details. The above ZIP file contains the .image and .changes files you need to browse the code and run the examples.
The source code for seven Squeak/DCI examples has been filed out as .HTML files for your convenience.
The code may look unreadable to a reader more used to a mainstream language such as Java or C#. The main stumbling block is the syntax for message passing.The mainstream syntax is
receiver.selector(arg1, arg2, ...)
e.g., fileDirectory.copy (file1, file2);
The Smalltalk (and Squeak) syntax is more informative:
receiver arg1Name: arg1 arg2Name: arg2.
e.g., fileDirectory copyFrom: file1 to: file2.
Internally, the Squeak compiler immediately transforms the above syntax to the mainstream form:
receiver arg1name:arg2Name (arg1, arg2).
e.g., fileDirectory copyFrom:to: (file1, file2)
This works because the colon (:) is a legal character in a message selector. It follows that the number of colons in a selector equals the number of arguments.
More about the Squeak language can be found at http://wiki.squeak.org/squeak/1859.
The links below give readable listings of the Squeak/DCI examples.
The listings have been produced programmatically from a Squeak image containing the BabyIDE development environment and all examples. See the Downloads section 'BabyIDE (Squeak / Smalltalk) Downloads >>
BB2Shapes - An animation of a universe of interacting objects
BB3Greed - A clumsy implementation of the game of Greed.
BB4Plan - A rudimentary program for activity network planning.
Two versions: BB4aPlan is implemented without DCI. BB4bPlan implemented with DCI.
The example illustrates one way of using DCI to support MVC.BB5Bank - The well known Bank transfer example
Illustrates A simple Context with two interacting Roles.BB6PayBills - Uses the above to pay a list of bills.
Illustrates that a Context can be instantiated and triggered from a RoleMethod.BB7Dijkstra - Implements a restricted form of the Dijkstra algorithm for finding the shortest route through a graph.
Illustrates recursion and different Roles being bound to the same object in the same execution. Builds on Jim Coplien's implementation of the same algorithm.BB8MoveShape - Consider a Draw program such as the PowerPoint slide editor. A user can create and place different shapes such as ovals, polygons, and lines. A Connector is a special line that runs from one shape to another. The line will always connect the two shapes even if the shapes move. This program implements the shape:move: operation.
BB9Planning (aka Prokon-3) An extended planning example that illustrates the combination of DCI and MVC.