[Newbies] Design with Visitor

math mathk.sue at gmail.com
Thu May 25 20:22:27 UTC 2006


Ron Teitelbaum wrote :
> Hi Mathieu,
> I've been thinking about how to respond to your question.  My first thought
> was to jump right in and help, but since this is a home work assignment it
> is probably best to help in a round about way.  What I didn't want to do was
> to discourage others that are working on homework from asking questions.
>   
Yes, I understand and I agree, in fact I did not express myself properly.
> So in order to help you I propose the following.  I will help to explain the
> patterns you mentioned, and I will critique your solution, all without
> helping you solve the problem you are trying to solve, so that you can
> benefit from doing and learning from your homework assignment.
>
> First the critique:  I really don't like your implementation of using a
> dictionary to handle your collection.  It seems to me that you are trying to
> accomplish something but I don't see what the benefit of that implementation
> is.  Can you tell me what functionality the dictionary adds?  What is the
> benefit of the dictionary over a simple collection?
>   

Thinking a bit more the appropriate term for my previous Performance
class should  be PerformanceFactory or something like this.
My idea is to provide a Performance per sport. But I have to consider
that only one TimeLaps or Distance should be added to a Performance.
So my difficulty first is to do this.

Thanks for your explanation of Visitor pattern.
In fact I already read it from "The design pattern Smalltalk companion"
book and I want to know the different way of implementation and if it
could be applicable for me.


>> From: math
>> Sent: Thursday, May 25, 2006 10:22 AM
>>
>>     
>>> Subject: Design with Visitor
>>> From: "Mathieu SUEN" <mathk.sue at gmail.com>
>>> Date: Wed, 24 May 2006 23:14:58 +0200
>>> To: beginners-bounces at lists.squeakfoundation.org
>>>
>>> Hi squeakers,
>>>
>>> I have to build  a lite code for home work.
>>> The objective is to gave to user a possibility to store his sport
>>> performance.
>>>
>>> So I have design a Class Performance(with PerformanceCollection) and I
>>> wanted to let things like TimeLaps, Date, Distance, and so on.
>>> for a later implementation (if we wanted to add others).
>>>
>>> So I provide a Measure abstract  class.
>>>
>>> Hence I add a dictionary in my Performance with the class for key and
>>> the instance for value:
>>>
>>> for example:
>>>
>>> Performance>>addMeasure: aMeasure
>>>           dictionaryOfMesure at: aMeasure class put: aMeasure
>>>
>>> Now I have to bring them in a Seaside UI so I guess that Visitor Pattern
>>> ( ;-) ) can help me but my complex structure mess my brain.
>>> So I ask you if you think that can be possible(and how) or other pattern
>>> can be more suitable for this problem.
>>>
>>> Thank you for your attention (:
>>> _______________________________________________
>>> Beginners mailing list
>>> Beginners at lists.squeakfoundation.org
>>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>>
>>>
>>>       
>> Thinking forward I see that 2 Performance instance couldn't be compare
>> so befor asking how to print them I will think about a other structure.
>> I think I will use Builder or Factory Method pattern.
>>
>> Thanks
>> _______________________________________________
>> Beginners mailing list
>> Beginners at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>>     
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
>   



More information about the Beginners mailing list