class composition

  • Thread starter Thread starter David Sobey
  • Start date Start date
D

David Sobey

sorry this may be a bit too generic for this newsgroup but neways:

I've got this:

class Event
{
reminder rem;
reccurance rec;
...other stuff;
}

When i need to check if a reminder needs to occur, i call
event.rem.checkreminder, however this function needs to access stuff in
the recurrance class. Obviously this can't happen.

I don't want to solve this problem with inheritence if possible, as
it's not really a logical modelling of the problem. And i also want to
avoid creating a function event.checkreminder, that passes "rec" to the
reminder class, as it doesn't make much sense either. Does anyone one
have some brilliant suggestions that will wash all my troubles away? :)

cheers!
dave
 
David said:
sorry this may be a bit too generic for this newsgroup but neways:

I've got this:

class Event
{
reminder rem;
reccurance rec;
...other stuff;
}

When i need to check if a reminder needs to occur, i call
event.rem.checkreminder, however this function needs to access stuff in
the recurrance class. Obviously this can't happen.

I don't want to solve this problem with inheritence if possible, as
it's not really a logical modelling of the problem. And i also want to
avoid creating a function event.checkreminder, that passes "rec" to the
reminder class, as it doesn't make much sense either. Does anyone one
have some brilliant suggestions that will wash all my troubles away? :)

cheers!
dave

Not knowing what reccurance does vs reminder I'm a little in the dark
but shouldn't reminder be inside reccurance? Can a reminder exist
without a reccurance and vice versa?

Chris
 
reminder and reccurance objects are always created when the event is
made. The reminder can be just a reminder for the first event occurance
(ie the event mighten even reccur at all, may be a once-only).

But sometimes the event does reccur (repeat), and the reminder needs to
check for those occurances too.

thanks!
dave
 
David said:
reminder and reccurance objects are always created when the event is
made. The reminder can be just a reminder for the first event occurance
(ie the event mighten even reccur at all, may be a once-only).

But sometimes the event does reccur (repeat), and the reminder needs to
check for those occurances too.

thanks!
dave

It sounds like the reoccurance should be contained inside part of the
reminder. That way reoccurance has access to it and the reoccurance
can't exist w/o the reminder.

Chris
 
ahh but what if it reccurs but has no reminder? as you can see,
reccurances and reminders aren't that related. hmmmm.... problems.
 
David said:
ahh but what if it reccurs but has no reminder? as you can see,
reccurances and reminders aren't that related. hmmmm.... problems.

You can have it both ways. Have reminder have a pointer to a
reccurance. Then if the reminder has a recurrance you just set the
property which saves the reference. That way if the reminder has no
reccurance the pointer just stays null.

Chris
 
yeah i'm heading that way. just.... bit messy that's all. not to worry,
seems my only option. Thanks for your help!

cheers
dave
 
Back
Top