I'm not sure if this is a good question.  Please forgive me if this is
one of the 'it depends' question without a use case.


Imagine these relationships: 1 A has many B, and 1 B has many C...

In reverse: C has 1 B, and B has 1A.  By transitivity, C has 1 A.


in DB, we have:

TableA
a_id

TableB
b_id
a_id (fk to TableA)

TableC
c_id
b_id (fk to TableB)


If a method in object C needs something from A to carry out the
operations...


solution 1.) the most obvious, but quite procedural way of doing OO:

> getB().getA().someMethod()

It works, but it doesn't smell right.  Some would say this is not OO,
but procedural programming with CFCs.  Correct?


solution 2.) let C have a reference to A, assigned by a setter or at
Init()

> variables.a.someMethod()

It works, but... C does not really have a reference to A in the DB, so
the DAO will be very different from DB, or is it considered okay?


solution 3.) Maybe the problem is wrong?  move the method into A, and
pass C in as argument

<cfcomponent name="a">
  function someMethod(C c) {

    // do things in A

    c.doSomething();
  }
</cfcomponent>


Thanks,
Henry Ho
--~--~---------~--~----~------------~-------~--~----~
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