On Tuesday 21 August 2001 11:22, Richard Staehli wrote:
I appreciate the need for initialization. Let's make it simpler than Java/ANSI Smalltalk by requiring a module to be a persistent immutable object. We should not care how an object came to be in a particular state, only that we can make a mutable copy of that state.
When you look at it this way, initialization code is just one way to create a copy of a particular object state and should not be fundamental to our definition of modules.
This is the style I prefer, as I have mentioned in other messages. But there are problems here as well.
If the "width" instance variable of a persistent object is 320, what does this mean? Could it really be 1/4 of the screen's horizontal resolution when the programmer created it? In that case it might have to be changed to 150 to work on my system.
You might argue that the program was broken in the first place and should be rewritten to explicitly maintain the proper invariants. But in practice most people come from a programming background where they depend on late initializations to get the job done. See http://www.colorforth.com for an extreme example.
As I have already said, both styles have their merits and we should think about them very carefully. Since I have adopted the "persistent objects, pre-initialized" approach I am working on solving its problems. But it isn't as simple as it seems.
-- Jecel