[Newbies] My customisation conundrum
Alain Plantec
alain.plantec at univ-brest.fr
Thu Jun 26 12:20:48 UTC 2008
On Thursday 26 June 2008 13:07:04 Nick Smith wrote:
>
> I'm a newbie to programming and I'm really enjoying learning Squeak, Seaside.
> One of the biggest delights for me is discovering just how expressive and
> powerful Smalltalk is when you can so easily add your own methods to the
> base classes. By using good intention-revealing selector names, I can write
> code that is almost self-explanatory.... like prose but not in the language
> of Smalltalk, in the language of the application/problem domain itself.
> This is brilliant. Every program you write is it's own DSL.
>
> So here's the thing I don't yet understand. If I embrace this way of
> programming and extend bases classes by adding my own methods, what happens
> to those methods when I upgrade my image to a newer version of Squeak? Is
> it that I need to subclass existing base classes before extending them (to
> better separate my code from the original) or perhaps I need to learn to use
> Traits; or is there something about Monticello that allows me to migrate my
> custom methods to newer images? Or maybe perhaps there's something I've
> missed completely.
You can use changes set or packages (with Monticello).
It seems to me that Monticello is what you are looking for.
By convention, a package XXX owns all classes that are
defined within a system category which name start with 'XXX-'
and owns all methods that are defined within a method category
which name start with '*xxx-'.
Let's try following example:
- Create a class A with 'XXX-base' as its system category
and a class B with 'XXX-util' as its system category.
- Open Monticello, click on '+package' button and type 'XXX'.
- Then select and browse XXX package ('Browse' button).
A package browser is opened on XXX package (showing your two system
categories 'XXX-base' and 'XXX-util').
- Now Browse class String with a standard browser, create a
method category named '*xxx-for-my-test'
(don't forget the $* at the beginning of the category name).
- Create a method within '*xxx-for-my-test', as an example:
forMyTest
^ self
- Then, open Monticello and browse your package again.
On left package browser list, select '*Extensions' item.
you should see your String>>forMyTest method in.
This means that String>>forMyTest owns to XXX package. Yes! you got it!
(this was the main subject of your question I guess).
Now the question is, how to save a package and import it
from another squeak image.
- For file out, select your package from Monticello then
select a repository (at least the local one is present)
and click on 'Save' button.
- Then open a file list and browse 'package-cache' sub directory.
you should see a file named 'XXX.<your-initials>.1.mcz'.
This is your XXX package.
- Then open another squeak image (a fresh one, without XXX package).
- Open a file list, browse 'package-cache' sub directory,
select 'XXX.<your-initials>.1.mcz'
and click on 'Load' button.
After that, your package is loaded, comprising extension
methods (your String>>forMyTest).
Cheers
alain
>
> Thanks.
More information about the Beginners
mailing list