Domaining using classes.

Michael van der Gulik squeakml at gulik.co.nz
Sun Aug 27 04:45:41 UTC 2006


Alexandre Bergel wrote:
>> Initially, "domaining using classes" has only a Person class. This  
>> class (and all other classes in the same image) belong to the  single 
>> #system domain by default.
>>
>> When an #employee domain or #student domain is created, instances  of 
>> Person become member of the respective domain as follows:
>>
>>  employeePerson := (Person clone nowYouClonedClassBelongsToDomain:  
>> #employee) new.
>>  studentPerson := (Person clone nowYouClonedClassBelongsToDomain:  
>> #student) new.

Umm... yea... whatever. It depends how its all implemented.

>> Observe when and where #new is executed. Then,
>>
>>  (employeePerson domain) printIt => #employee
>>  (studentPerson domain) printIt => #student
> 
> 
> What is the difference between this and a classical namespace ?
> 
> With namespaces I would have:
> employeePerson := Employee.Person new.
> studentPerson := Student.Person new.

Domains are used for managing resources.

Namespaces are used for managing the uniqueness of class names.

Many objects of the same class (and thus in the same Namespace) could be 
in different domains.

The concept of a "Domain" is my own invention, and I'm not entirely 
happy with the name; it's already overused in many areas of computer 
science. Perhaps "ResourceDomain" would be a better name?

Also; don't get too caught up with implementation details. At the moment 
I've got working code which basically copies a class, adds a domain 
instance var to that class object and returns a new object of that 
class. It works, but it's a big hack and is only excusable because I 
couldn't think of a better way of implementing it without massive VM 
changes.

Ideally, there would be VM changes which would group objects of the same 
domain physically in memory.

I also think a Domain like I'm using it is just like Lex Spoon's 
Islands, so I'll be looking at his code soon. Incidentally, it seems 
I've implemented one of the few things he didn't - managing memory usage.

Islands: http://minnow.cc.gatech.edu/squeak/2074

> (employeePerson class namespace) printIt => #employee
> (studentPerson class namespace) printIt => #student
> 
> 
> What is the impact of domaining on the method lookup ?

Hopefully none, but that's dependent on how it is all implemented.

When my code is usable by others, I'll be putting it online somewhere.

Cheers,
Michael.




More information about the Squeak-dev mailing list