I note that #become: is not in the ANSI Smalltalk standard (am I the last
person in the world to care about that? Probably) and that several of the
Smalltalk systems I have on my machine don't support it.
In Squeak 5.2, there were 17 references to #become:.�� Four of those were
just testing it.�� One is just a mention in a collection of dangerous
things to not be tried.�� Several are ways of changing an object's class.
Several are ways of forcibly deleting an object by turning it into
something trivial but safe.�� And a couple, I don't understand.�� Thing
is, #become: is *not* something to do lightly, and the code that calls
"x become: y" should "own" both x and y.�� (In fact one of them is
often "self".)

About The Design Patterns Smalltalk Companion, draft chapters are
When I read the Gang of Four book, it seemed to me that most of it was
about fighting the fact that C++ and Java aren't Smalltalk.�� Read a draft
chapter or two to make up your own mind.

One difference between the State pattern and #become: is that an object
can be an instance of the State pattern in more than one way at the same
time.

On Thu, 17 Jan 2019 at 05:58, Ben Coman via Pharo-users <pharo-users@lists.pharo.org> wrote:


On Wed, 16 Jan 2019 at 17:16, Lo��c Pag��s <loic.pages@inra.fr> wrote:
Dear Pharo users,

I develop software dedicated to the simulation of plant development and
3D architecture.

In the past, I used Java,��
but I am very interested in translating code
in Pharo. I appreciated very much the language and the course.

I have a question for you all :

During plant development (ontogeny), new organs appear, that are
gradually tranformed. For example, a bud can make a flower, and then a
fruit.

Organs are conveniently modelled as classes. During the course, I
learned that it was better to make several classes (bud, flower, fruit)
instead of a "fat class" such as "reproductive organ" with many
attributes and stages (bud stage, flower stage, fruit stage). I wonder
how to transform an object into another one, to represent for example
the fact that the flower may become a fruit.

Maybe a naive question ?

Maybe #become: ...

but it might be a misuse for your purpose.�� The following book will provide some good insights...

cheers -ben


��