Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
PackageInfo
Last updated at 3:58 pm UTC on 12 January 2022

PackageInfo: Declarative Categorization of Squeak Code


The PackageInfo system is a simple, lightweight way of organizing Smalltalk source: it is nothing more than a naming convention, which leverages the existing categorization mechanisms to group related code.

For example: say that you are developing a framework named SqueakLink to facilitate using relational databases from Squeak. You will probably have a series of system categories to contain all of your classes, eg,
('SqueakLink-Connections' OracleConnection MySQLConnection PostgresConnection)
('SqueakLink-Model' DBTable DBRow DBQuery)
and so on. But not all of your code will reside in these classes! For example, you may also have a series of methods to convert objects into an SQL-friendly format:
Object>>asSQL
String>>asSQL
Date>>asSQL
These extensions belong in the same package as the classes in 'SqueakLink-Connections' and 'SqueakLink-Model'. You mark this by placing those methods in a method category (of Object, String, Date, and so on) named '*squeaklink' (note the initial star). The combination of the 'SqueakLink-...' system categories and the '*squeaklink' method categories form a package named "SqueakLink". The rules, to be precise, are this: a package named "Foo" contains To get a feel for this, try this in current image that contains both PackageInfo and *Refactoring Browser*. The Refactoring Browser code uses PackageInfo's naming conventions, using "RefactoringEngine" as the package name. (CHECK IF THIS STILL APPLIES) In a workspace, create a model of this package with
 refactory := PackageInfo named: 'RefactoringEngine'. 
It is now possible to introspect on this package; for example, refactory classes will return the long list of classes that make up the Refactoring Engine and the Refactoring Browser. refactory coreMethods will return a list of MethodReferences for all of the methods in those classes. refactory extensionMethods is perhaps one of the most interesting queries: it will return a list of all methods contained in the RefactoringEngine package but not contained within a RefactoringEngine class. This includes, for example, ClassDescription >> chooseThisClassInstVarThenDo: and SharedPool class >> keys.

Since the PackageInfo naming conventions are based on those used already by Squeak, it is possible to use it to perform analysis of code that has not explicitly adapted to work with it. For example, (PackageInfo named: 'Collections') externalSubclasses will return a list of all Collection subclasses outside the Collections categories.


You can send #fileOut to an instance of PackageInfo to get a changeset of the
entire package.

Further reading

For more sophisticated versioning of packages, see the Monticello Basics project.