I (and subclasses) am a library of of assets (images, icons, strings, etc), to be used by an application. My methods which return Smallalk objects, can be tagged to specify a file "links" external files in as Smalltalk objects during development time. The method used to turn the file contents into a Smalltalk object is a negotiation between the file's type (extension) and methods provided by the receiver.

Implementation Details:
Asset classes are singletons. There is never a need to create instances of them. Assets are retrieved by simply sending the name of the asset to the them.

A preliminary asset method might look like this:

myIcon
	<file: 'somePath.png'>

After it has been "integrated, it would look something like:

myIcon
	<file: 'somePath.png'>
	<md5sum: #[1 2 3 4 5 6 7 8]>

	^[CachedImage on: (Image extent: 2@2 depth: 1 bitsPerPixel: 1 palette: (Graphics.MappedPalette withColors: (#(#(#{Graphics.ColorValue} #scaledRed:scaledGreen:scaledBlue: #(0 0 0)) ) collect: [:each | (each at: 1) value perform: (each at: 2) withArguments: (each at: 3)])) usingBits: #[0 0 0 0 0 0 0 0])] once

The following is an explanation of the various parts:

- File Specifier: (<file: 'somePath.png'>)
The first tag is used to link the method with an external resource. The external resource is specified by the argument which is path to a file. The method that is used to "integrate" the external source file into a reproducible Smalltak object, is determined by the file's extension type. In this case, 'png'. Each import type needs to have a method called import_<extension>: if it is to integrate that file type. For example, the one used in this case is import_png: By default, there is support for gif, jpeg, jpg, bmp, and png. You can add to this set or override them, in either your own subclass or by extending the base Assets class.

- Remembered Hash: (<md5sum: #[1 2 3 4 5 6 7 8]>)
The second tag (i.e. md5sum:) shows up after we have "integrated" the external file with the method. It is a snapshot of the md5sum of the external file at the time of integration. It can then be used to determine at future points which assets need to be reintegrated because the hash of their external files no longer matches that of the method.

- Once Block: (^[....] once)
Though the return value of an asset method is an object generated by importing from an external resouce file, it is considered a must that after that fact, the method be able to reproduce the object without the resource file. This is necessary because applications shouldn't require big directories full of files. Applications must be able to be loaded from Store or Parcel without external file references.

The code to recreate the object goes in the block. The message once is special. It is like value, in that returns the value of the block. But the value returned is that as rememebered from the first time the block was sent this message. For example, if the contents of the block were to create a new OpaqueImage of moderate size, each time we asked for this asset, performance would be dismal. It would a waste of both cpu cycles and memory. This technique is more than 100 times faster than the former 'ListIconLibrary visualFor: aSymbol' technique.