[Cuis-dev] Saving a CodePackage and determining its class when installing it

Nicolás Papagna Maldonado nicolas.papagna at gmail.com
Sun Oct 25 08:04:40 PDT 2020


Hi Folks,

For some experiments I'm doing, I've created a subclass of CodePackage
(let's call it FakeCodePackage) to make my tests run fast that avoids
accessing Smalltalk or SystemOrganization.
When I filed-out the package and installed it in a fresh image, to my
surprise, the newly installed package was an instance of FakeCodePackage.

After poking around, I found this method in CodePackage that is used when
saving an instance:

codePackageClass
  "Answer the specific CodePackage subclass to use."

  self class == CodePackage ifFalse: [
    ^ self class ].
  self classesDo: [ :cls |
    (cls inheritsFrom: CodePackage)
      fTrue: [ ^ cls ]].
  ^ nil

This means that whenever there is a subclass of CodePackage in the package
being saved, It is assumed that is the class that should be used to
re-creating the CodePackage instance when installing it.

In my case, FakeCodePackage is not fully functional as I use it only in my
tests, so I was unable to either delete the package or re-install it
because of all sorts of errors.
Luckily this was a fresh image, so I had nothing to lose :)

I was wondering what is the use case for that, and if it still relevant/in
use.

Cheers!
Nico PM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20201025/2907dba7/attachment-0001.htm>


More information about the Cuis-dev mailing list