My customisation conundrum

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

My customisation conundrum

Nick Smith
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.

Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: My customisation conundrum

David T. Lewis
On Thu, Jun 26, 2008 at 04:07:04AM -0700, 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 will want to learn about change sets and Monticello. Here are some
explanations of change sets:

  http://wiki.squeak.org/squeak/785
  http://wiki.squeak.org/squeak/946
  http://wiki.squeak.org/squeak/674

and Monticello:

  http://wiki.squeak.org/squeak/1287
  http://wiki.squeak.org/squeak/43

I would suggest getting comfortable with change sets as a first step.

Dave

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: My customisation conundrum

Alain Plantec
In reply to this post by Nick Smith
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.


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners