|
Prev: Building Hibachi
Next: FAST CASH $6 PAYPAL
From: Graham on 4 Apr 2008 04:02 On Apr 3, 9:41 pm, Maciej Sobczak <see.my.homep...(a)gmail.com> wrote: > On 3 Kwi, 17:29, Graham <graham.st...(a)virtual-worlds.biz> wrote: > > > package Payment_Stream_Package is new Ada.Containers.Ordered_Maps( > > Element_Type => Money, > > Key_Type => Positive ); > > > type Payment_Stream is new Payment_Stream_Package.Map; > > Instead of a solution, I have a question: > > Why do you derive from Map? Which operations of Map do you plan to > override? > > Do you ever plan to pass Payment_Stream where > Payment_Stream_Package.Map'Class is expected? What effect would you > like to achieved this way? > > Why derivation and not composition? > > -- > Maciej Sobczak *www.msobczak.com*www.inspirel.com Good question. The intention was not to derive from Map at all: I simply wanted to keep the fact that it was implemented as a Map private. Is there a better way of doing that, or is keeping it private overdesign? Graham
From: Adam Beneschan on 4 Apr 2008 11:57 On Apr 4, 1:02 am, Graham <graham.st...(a)virtual-worlds.biz> wrote: > On Apr 3, 9:41 pm, Maciej Sobczak <see.my.homep...(a)gmail.com> wrote: > > > > > On 3 Kwi, 17:29, Graham <graham.st...(a)virtual-worlds.biz> wrote: > > > > package Payment_Stream_Package is new Ada.Containers.Ordered_Maps( > > > Element_Type => Money, > > > Key_Type => Positive ); > > > > type Payment_Stream is new Payment_Stream_Package.Map; > > > Instead of a solution, I have a question: > > > Why do you derive from Map? Which operations of Map do you plan to > > override? > > > Do you ever plan to pass Payment_Stream where > > Payment_Stream_Package.Map'Class is expected? What effect would you > > like to achieved this way? > > > Why derivation and not composition? > > > -- > > Maciej Sobczak *www.msobczak.com*www.inspirel.com > > Good question. The intention was not to derive from Map at all: I > simply wanted to keep the fact that it was implemented as a Map > private. Is there a better way of doing that, or is keeping it private > overdesign? No, that's the sort of thing you're supposed to do. If you had derived it in the visible (public) part, you're telling all users of the package that all the operations available on Payment_Stream_Package.Map are available for a Payment_Stream, and that's apparently not what you want. So doing what you did is the right thing. I suspect Maciej just missed the fact that the derived type declaration was in the private part. -- Adam
From: Robert A Duff on 4 Apr 2008 13:25 Graham <graham.stark(a)virtual-worlds.biz> writes: > Good question. The intention was not to derive from Map at all: I > simply wanted to keep the fact that it was implemented as a Map > private. Is there a better way of doing that,... You could say: type Payment_Stream is record M : Payment_Stream_Package.Map; end record; which might be better, depending on what you want. >... or is keeping it private > overdesign? No. - Bob
From: Simon Wright on 4 Apr 2008 15:37
Robert A Duff <bobduff(a)shell01.TheWorld.com> writes: > Graham <graham.stark(a)virtual-worlds.biz> writes: > >> Good question. The intention was not to derive from Map at all: I >> simply wanted to keep the fact that it was implemented as a Map >> private. Is there a better way of doing that,... > > You could say: > > type Payment_Stream is > record > M : Payment_Stream_Package.Map; > end record; > > which might be better, depending on what you want. You could also, for example, include a mutex in the record for locking in the presence of concurrency. |