Grasping the concept of Classes & Categories

Daniel Salama dsalama at user.net
Thu Jun 16 18:38:26 UTC 2005


Thanks Brian. You've confirmed my suspicious.

- Daniel

On Jun 16, 2005, at 1:19 PM, Brian Brown wrote:

>
> On Jun 16, 2005, at 10:52 AM, Daniel Salama wrote:
>
>
>> Hello all,
>>
>> I've been playing with Squeak for some time and have a question.  
>> if I wanted to use a Squeak instance to serve different  
>> applications (say multiple applications using Seaside), how unique  
>> do classes need to be? Sorry for the vague question. Let me be  
>> more specific.
>>
>> I have two applications that both need a class Customer. However,  
>> one of the application requires that class Customer have a set of  
>> attributes and methods very different from the second application  
>> who uses the class Customer for a totally different industry.
>>
>> If I create a category for each of the applications, can I have a  
>> class Customer for Category A and another class Customer for  
>> Category B?
>>
>
> If they have different names, yes :-)
>
> I would approach it in a different way, like have a CustomerBase  
> class that has all the attributes and methods that are common to  
> both your industry specific customer types, then have IndOneCust  
> and IndTwoCust subclasses that implement the specific attributes,  
> methods, etc. for each of those. (Obviously you would want to use  
> more indicative names for your subclasses.)
>
> Each of those subclasses can be in different categories.
>
> hth,
>
> Brian
>
>
>
>>
>> In a way, I think I'm going to try to answer the question myself,  
>> but would prefer to get clarification or validation from you guys,  
>> who are much more experienced than me. The Smalltalk way would be  
>> to reuse code as much as possible. Therefore, I should probably  
>> carefully design a class Customer so that it may be sub-classed  
>> into more specialized classes such as IndustryACustomer and  
>> IndustryBCustomer. Is this the Smalltalk mentality? Coming from  
>> other environments which don't "encourage" you to work efficiently  
>> may be what's confusing me.
>>
>> Thanks,
>> Daniel
>>
>>
>>
>>
>
>
>




More information about the Squeak-dev mailing list