Design Question: Delegation vs. callbacks

Daniel Keep daniel.keep.lists at gmail.com
Sun Jun 17 02:10:00 PDT 2007



Henning Hasemann wrote:
>>    Normally, I'd expect thing (or widget) to be a base class for many 
>> graphics objects.
> 
> Ok, Ill give some more detail here:
> My project is an engine for classical 2D adventures (like the old
> LucasArts ones).
> A thing is everything the player can interact with. I.e it might be
> another character, or something to pick up or to push, ...
> 
> A thing needs an area to be able to receive mouse clicks, but I need
> areas in other places, too (for example in 'regions' when I want to
> trigger events as soon as the character stands at a certain place)

I'd be tempted to have an IHasArea interface which both Thing and Area
implement.  In the case of Thing, it would pass the call on to an
internal Area object.  That, or you could always expose the Area object
(although that's a bit risky until we get D2.0 and const).

	-- Daniel


More information about the Digitalmars-d-learn mailing list