I don't think I can give you an answer that is right you have to make that
decision. What I do with my developers working on these types of design
decisions is give them some questions to ask themselves in hope that it will
get them to an answer. At the end of the day, especially when you start, you
will regret your decision for one reason or another so you want to mitigate
as much risk of making the worst decision by asking some questions...
Remember you must answer these I am not saying yes or no to any of them.

>Have the event object just query the database and populate the array
itself.

Is your event object becoming too smart at this point? Should it know where
calendars live? Where does the rest of your persistence interaction live?
How will you write a test case to test your object's behavior without
relying on a database?

>Have the event object ask the calendarManager for the array.

How will this impact your coupling? Is this impact acceptable? Is there an
alternative to this approach that could impact it differently? How will you
write a test case to test your object's behavior without relying on a
database?

>Pass the array into the constructor when creating the event object.

How big is this array? Will all of these objects be used or will the
creation be wasted? Are there alternative constructors? Can my object exist
and work without this array? How will you write a test case to test your
object without relying on a database?

The only one I have a clear direction for is the last question "Can my
object exist and work without this array?" If the answer to that is no then
I would strongly recommend going this direction. From the sounds of it that
is not the case. Note I have a repeat question in all of them, "How will you
write a test case to test your object's behavior without relying on a
database?" Part of the benefit of TDD, objects that are hard to test tend to
be objects that violate design principles. Easy testing objects tend to be
good citizens.

Does anyone else have any good architecture questions Steve can ask himself
to help him make the decision?

Adam Haskell



On Wed, Mar 26, 2008 at 10:58 AM, Stephen Judd <[EMAIL PROTECTED]>
wrote:

> I'm taking my first plunge into a fully OO application and have what I
> think is a simple question, though I haven't found the answer through
> searching:
>
> I'm developing an events calendar.  An event can be on more than one
> calendar, so when I display an individual event, I want to also display
> which calendars it's on.
>
> So, when I construct my event object (I know, confusing name) what's the
> best way to grab an array of the calendars it occurs on?  I'm thinking the
> array could be a property of the event, but I'm not sure that my event
> should be asking the calendarManager for the array directly.
>
> Options I've contemplated:
>
> Have the event object just query the database and populate the array
> itself.
>
> Have the event object ask the calendarManager for the array.
>
> Pass the array into the constructor when creating the event object.
>
>
> Any thoughts?  is this where I need to start using and learning
> ColdSpring?
>
> Thanks, Steve
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to