## Metagnostic home
| # Experimental stuff for Dolphin Smalltalk
  Goodies JNIPort Z-Kit ListTree Space Breakdown F.M.B. Ghoul Miscellanea Experiments Changes Prerequisites Licence | This page collects together some miscellaneous experimental stuff. That's to say, stuff that I've been playing with, but — for one reason or another — haven't finished or don't take seriously enough to “freeze”. You could say that this is a collection of code that I think someone might be interested to see but probably not actually use. In some cases I write a package just to see how the code fits together rather than out of any real need to use it — which, if I publish it at all, obviously means that it belongs here. 3-Way Sorting is an example of such purely experimental code. Another reason for a package to be here is that although it might be interesting to others, and is mature code that I use a lot, it was really only designed for my own idiosyncratic uses; the Browser Database is an example. In still other cases I've put together code because I know will need it later, and the only reason that it's here is that that “later” hasn't happened yet ;-) and so I consider it to be immature (for instance the Selection From List Presenter). It's sometimes pretty arbitrary whether a package ends up in this collection, given its own page, or dumped into Miscellanea. In general I'm using the rule that stuff should still be considered to be immature until I've used it for a few things myself. Given the nature of these packages, the level of documentation is variable — most typically in the range from poor to non-existent. Some packages and classes have comments, most do not (methods do have comments — as a matter of course). Also, because much of this code is still immature, I have no particular intention of following my normal version number discipline. If I make changes, then I'll change the version numbers, but whether I change the major or minor number, and by how much, will depend on the phase of the moon, or on some other whim. The packages are (in alphabetical order): 3-Way Sorting It has always seemed odd to me that we insist on representing the result of a comparison by a Boolean value when there are three possible results. This package defines a method, `#<=>`, and three classes (modelled on the `True` and `False` classes) for doing three-way comparison and representing the results. The idea is that the `ComparisonResult` objects invoke polymorphically varying behaviour, so you can say things like:
      	(aString <=> anotherString)
      		ifMore: ["some code"]
      		ifSame: ["some other code"]
      		ifLess: ["still more code"].
  Three-way comparison should also allow more efficient sorting (since more information is available to the algorithm from each comparison operation). The package includes a preliminary and incomplete `ThreeWaySortedCollection` which implements a 3-way QuickSort (it's supposed to provide other algorithms too, but I haven't written that yet). Status: purely experimental, incomplete, partially documented. Browser Database There are a number of things that it would be nice to do in the Dolphin IDE that need a fast way of checking cross-references between methods. The Browser Database provides that. It builds up an internal database (taking around 1MByte in my image) of which methods refer to, or are referred to by, which. Then it maintains that data by hooking the system change notifications, and rebuilding the tables as methods are changed or otherwise recompiled (e.g. because of a class definition change). Once the database has been built (which takes several seconds), you can issue various queries about cross-referencing. Since rebuilding the data can slow down the system somewhat (especially if you change the definition of a class with many subclasses), the database can be paused or stopped, and then re-started later. When the package is first loaded, the database is not active, but can be activated by evaluating:
      	BrowserDatabase current beRunning.
  This package also includes three applications of the database, all are new virtual method categories. One marks methods that are overridden in a subclass; one marks methods that are not referred to anywhere; and the last marks methods that refer to undefined methods. Status: stable (I use it constantly), idiosyncratic, largely undocumented. Browser Database UI A simple “Additional Tool” that provides a GUI for controlling (starting, stopping, pausing) and monitoring the current Browser Database. Status: stable, idiosyncratic, undocumented, trivial. Derived List Model A DerivedListModel is a ”view“ (in the database sense) of another ListModel, mediated by a filter block, and allowing its elements to be sorted without affecting the underlying ListModel. This package also includes a flavour of ListPresenter that is able to make proper use of DerivedListModels. Status: immature, documented. Easter A few loose methods added to the Date class for calculating Western Christian Easter in various years. This code is based on an algorithm that is plastered all over the Web. Status: stable, would be in Miscellanea if it weren't so limited in scope, not to mention being specific to a rather restricted culture. Enhanced Scrolling Decorator A slightly enhanced version of the Dolphin `ScrollingDecorator`. It differs in that you can control whether it has horizontal and vertical scrollbars independently. Similarly you can set whether it stretches the decorated View horizontally or vertically (if that is smaller than the scrollable area). Status: immature (in occasional use), not much documentation (but I'm not sure that it needs more). Enhanced Static Text A slightly enhanced version of the Dolphin StaticText. You can control how text is aligned both horizontally and vertically, and whether it erases its background before painting the text. Status: immature, and how much documentation can something so trivial need ? Expression Timer A utility for timing expressions; it is intended to make some sort of pretence at statistical validity, rather than just running the expression several times and averaging the runtimes. It is undoubtedly over-elaborate (it's very old code), but I may make it even more elaborate someday by sticking a GUI on it… Status: stable (I've been using it for ages), idiosyncratic, over-documented. Extra Categories Three additional virtual method categories. One marks loose methods (ones that are not in the same package as their class). The second marks methods that appear to use Smalltalk's reflective and meta-programming features (such as `#become:`, `#isKindOf:`, etc). This is implemented as an application of a more general method category class whose instances mark methods that refer to any of a configurable list of symbols. The last marks methods that define/override the meta-programming methods. Again, it is defined as an application of a more general method category class which is defined by a list of selectors. Status: stable (in constant use), idiosyncratic, documented. Extra Collections Some additional Collections implementations: Arrays of 1-bit quantities implemented as bitmaps. These also define fast logical and boolean operations (xor, etc) between pairs of such arrays. A fast implementation of sets of integers drawn from a small(-ish) range. Uses a bitmap internally. A specialised Set that is optimised for finding elements with a particular “key”. Status: immature, documented. Form Layout A layout manager that lays out components as a list of <label, value> pairs. Status: immature, documented. Graphics Base I've added this package to the Experiments page only because it and the 'CU Printing' package are designed to work together. This is work in progress. Status: See Printing. LRU Cache A simple implementation of a Dictionary with fixed maximum capacity, and which uses a Least-Recently-Used algorithm to evict ”unused“ key-value pairs in order to make room for new elements. Status: immature, documented. PolyViewer The easiest way to explain this one is to give something of its history. When I started programming Dolphin, I found that many of the applications I was considering followed the same pattern for their GUIs — they consisted of a single Model and a tabbed collection of different Views onto that (shared) model. Exactly which Views were needed would depend not only on the application, but also on more dynamic considerations, such as what the user (typically me) wanted to do at the time. So I ended up putting together what I called the “PolyViewer Framework” in which an application is defined as a shell into which a dynamically configurable number of pluggable sub-views can be added as independent tabs. Each sub-view also defines what items it wants on the shell's main menu, and one of the jobs of the framework is to merge the various menus (eliminating duplicate commands). It also has features to allow pluggable extensions to the menus with commands that are not implemented by a specific tab. I've always intended to provide a way of building (dynamically) a toolbar by merging the sub-views' own toolbar specifications, but I've never finished that bit… This is pretty old code, and could do with a bit of a polish-up and some simplification (not to mention finishing the toolbar stuff). But, on the other hand, it works as it is, so why mess with it ? Status: stable (in constant use), incomplete, some documentation. Printing This is the start of an attempt at a printing framework. It is, as yet, not only incomplete, but also I know that quite large chunks of it will be redesigned. I do already use it for a couple of real applications, but it's not by any means ready for prime-time. I include it in this collection because there don't seem to be many examples of doing printing from Dolphin (Ian Bartholomew has some example, of course, but he uses a rather different approach mostly based on the Rich Text controls, whereas this just draws raw graphics). There's virtually no documentation (since the design is still fluid), but if you are interested then you can open a print preview of an example document by evaluating:
      	provider := ExamplePageProvider pageCount: 21.
      	(PrintPreviewShell showOn: provider)
      		isLandscapeView: true;
      		isSmallView: true;
      		yourself.
That creates a “page provider” (which is any object that knows how to draw a requested page onto a region of a canvas), and then passes it to a print-preview window which can show the pages in various ways. If you ask the preview window to print the “document” then it will launch a printer select/setup dialog, and then pass the page provider to a print-progress window which will, in turn, send the selected pages to the printer. This requires Ian Bartholomew's 'Printer WinAPI' package which is available as part of his (excellent) goodies collection here. Status: very immature, incomplete, in flux, undocumented, you have been warned… Quick Deploy Quick Deploy is a simple GUI tool to provide nearly-one-click-deployment (actually, it's more like three-clicks, but that's good enough for me). It is intended to help make deployment from a clean image (which is the only sensible way of doing deployment, in my opinion) simple and convenient. The package comment gives details of how best to use it. Status: stable, idiosyncratic, documented. Safer Maths This adds a few methods to `LargeInteger` and `Fraction` which eliminate some avoidable floating-point overflows when working with very high precision Integers and Fractions. Note that most such overflows are not avoidable! Status: stable, should probably be in Miscellanea. Selection From List Presenter A kind of Presenter that allows a user to select several items from a list, and (optionally, depending on the View) to choose their order. It looks like the 2-pane selection components used by Windows in various places. (I have once seen this kind of UI component called a “shuffle-box” — I like that name, but I don't think it's in wide use.) It is intended to be more-or-less a straight plugin replacement for a ListPresenter showing a multiple selection list view. This package also includes replacements for `ChoicePresenter` and `ChoicePrompter` that use this component instead of a multiple-selection list view. Status: immature, documented. Simple Resource Plugin A simple plugin for the Dolphin class, and system, browsers that allows you to manage and browse the selected class's resources. This is an enhanced version of the code I posted to comp.lang.smalltalk.Dolphin at the end of January 2005. Status: immature (I don't actually use this myself, but use a different implementation of the same concept), lightly documented. Valuable as Value This rather weird (and largely untested) hack allows a Block to be used in place of a ”normal“ value (automatically evaluating itself on each use). This is code I posted to comp.lang.smalltalk.Dolphin at the end of January 2004. Status: just plain weird. Wave Out Small package that wraps (some of) the low-level Windows "Wave Out" APIs for playing sounds. It provides player objects that can play buffers of wave data held in memory, rather than being limited to reading data from files. The players can also be configured to run in an infinite loop, recycling the buffers and refilling them by computing new data on demand. Status: immature, documented. Weirdness A little demo of some ways to use Dolphin to produce an unconventional user interface. It requires the 'WalicXe - Widgets' package from here and and Udo Schneider's 'US LayeredView' package from here. Status: merely a demo. ### Packages
Package sizes and versions
Name | Size | Version
--- | --- | ---
CU 3-Way Sorting | 40813 | 1.01
CU Browser Database | 45875 | 1.04
CU Browser Database UI | 15784 | 1.04
CU Derived List Model | 23656 | 1.00
CU Enhanced Scrolling Decorator | 13841 | 1.02
CU Enhanced Static Text | 18940 | 1.00
CU Easter | 5064 | 1.00
CU Expression Timer | 32997 | 1.04
CU Extra Categories | 12754 | 1.01
CU Extra Collections | 54817 | 1.06
CU Form Layout | 27356 | 2.01
CU Graphics Base | 135733 | 0.0150
CU LRU Cache | 15955 | 2.00
CU PolyViewer | 85322 | 1.03
CU Printing | 79110 | 0.0031
CU Quick Deploy | 35713 | 4.04
CU Safer Maths | 4739 | 1.00
CU Selection From List Presenter | 70640 | 1.04
CU Simple Resource Plugin | 18785 | 1.05
CU Valuable as Value | 3774 | 1.00
CU Wave Out | 84283 | 1.08
CU Weirdness | 32896 | 1.13
Prerequisite packages' sizes and versions
Name | Size | Version
--- | --- | ---
CU Abstract Collections | 51193 | 4.02
CU Always | 5976 | 3.01
CU GDI Extensions | 10083 | 0.0004 (unpublished)
CU Hashed Pair | 10870 | 1.00
CU Package-relative File Locator | 11829 | 3.01
CU Sortblocks | 16398 | 3.01
CU Storage Size | 1809 | 1.00
CU String Extensions | 6885 | 1.00
CU Tools Base | 34422 | 0.0009 (unpublished)

Copyright © Chris Uppal, 2003-2005