Domaining using classes.

Alexandre Bergel Alexandre.Bergel at cs.tcd.ie
Thu Aug 24 14:14:05 UTC 2006


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

(employeePerson class namespace) printIt => #employee
(studentPerson class namespace) printIt => #student


What is the impact of domaining on the method lookup ?

cheers,
Alexandre



Am Aug 24, 2006 um 10:57 AM schrieb Klaus D. Witzel:

> Hi Alex,
>
> can we keep this discussion thread in squeak-dev (and if so then  
> please don't reply just to me).
>
> On Thu, 24 Aug 2006 10:55:40 +0200, Alexandre Bergel wrote:
>
>>> Domain a and domain b have precisely the same superclass (oop).  
>>> So the answer is: always the right one, since there exists only  
>>> one implementor.
>>
>> It means that a client is always in one (and only one) domain. How  
>> those domains are composed each other ?
>>
>> For instance, a short example of a class Person that has two  
>> domains: employee and student.
>
> 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.
>
> Observe when and where #new is executed. Then,
>
>  (employeePerson domain) printIt => #employee
>  (studentPerson domain) printIt => #student
>
>  (employeePerson class) printIt => 'a Person in domain #employee'
>  (studentPerson class) printIt => 'a Person in domain #student'
>
>> Person>>employeeDomain.salary
>> 	^ 2000
>>
>> Person>>studentDomain.nbOfCoursesTaken
>> 	^ 4
>>
>> Easy.
>
> I think that our subject "domaining using classes" does not have  
> such methods. The methods do not change when domain membership  
> becomes effective (i.e. do not have the domainName. prefix from  
> your examples), they change neither automagically nor manually.
>
>> the method salary can be invoked by an object x only if x "is" in  
>> a domain employee. Same thing for nbOfCourseTaken.
>>
>> Imagine now the few methods:
>>
>> "Public methods"
>> Person>>employeeDomain.printString
>> 	^ self printOn: (WriteStream on: String new).
>>
>> Person>>studentDomain.printString
>> 	^ self printOn: (WriteStream on: String new).
>>
>>
>> Person>>printOn: stream
>> 	self generalInfo printOn: steram		"CRITICAL QUESTION HERE"
>> 	self description printOn: stream		"CRITICAL QUESTION HERE"
>>
>> Person>>employeeDomain.description
>> 	"Description for being an employee"
>
> An instance of Person in domain #employee does not have the "is an  
> employeePerson" property. Instead, it has the "my class belongs to  
> the #employee domain" property. This implies that the "domained"  
> Person instance belong the their class' domain.
>
>> Person>>employeeDomain. generalInfo
>> 	"Description for being an employee"
>
> Same as above.
>
>> Person>>studentDomain.description
>> 	"Description for being a student"
>
> Same as above with s/employee/student/.
>
>> Person>>studentDomain. generalInfo
>> 	"Description for being a student"
>
> Same as above with s/employee/student/.
>
>> printOn: is not part of any domain (or belongs to a 'default'  
>> domain). When printOn: is invoked, how do you know the right  
>> method to select ?
>
> Since we have "just" clones of classes, we always select the right  
> method, because only that one method exists?
>
>> What does it mean to "be" in a domain ?
>
> Any class can be cloned and the clone is added to a domain (a  
> domain has an identifier and a collection of members, i.e. a  
> collection of cloned classes). Instances of a domained class belong  
> to their class' domain.
>
>> I am really interested by this discussion!
>
> :)
>
> /Klaus
>
>> cheers,
>> Alexandre
>

-- 
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.cs.tcd.ie/Alexandre.Bergel
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






More information about the Squeak-dev mailing list