View Single Post

  #1 (permalink)  
Old 12-04-2005, 02:59 AM
panu
Guest
 
Posts: n/a
Re: Newbie question: immutable objects in Smalltalk

Chris Uppal wrote:

> Smalltalk /programmers/ do make a fairly strong distinction made between
> private and public, but that's a convention rather than something built into
> the language. It is communicated in various ways, and with various degrees of
> effectiveness


An alternative to this is to use a pattern which in fact is implicit
in Smalltalk already: "Make ALL methods public. Instead of defining
private methods, delegate to private components".

In other words, if you think you want some method be private,
why not instead refactor that functionality into a component!?

From another viewpoint this is very close to the Bridge -pattern:
Keep implementation and interface in separate objects. Many good
things follow. For instance, 'implementation' can now inherit
via a different path than the interface, reducing coupling. The
implementation can also be replaced at runtime, to represent
changing state.

As to immutability, the methods of the object still control
that. But, I believe in Dolphin 6, you can explicitly set an
object to be immutable too.

- Panu Viljamaa


Reply With Quote