On Wed, Jun 7, 2017 at 3:34 PM, sebb <[email protected]> wrote:
> cttee1 = ASF::Committee.preload
> cttee2 = ASF::Committee.load_committee_info
>
> cttee1 gets the LDAP committee info
>
> cttee2 gets info from committee-info.txt
>
> I find this rather confusing, and it seems to me that it is
> error-prone and a bit of a maintenance headache, because the Committee
> class is now defined in multiple files. If the same method name is
> defined in two classes, which one will be used? I suspect it will
> depend on the order the files are loaded.
>
> Similar considerations apply to the Person class

I'm not sure I understand this comment.  In particular, do you have an
example where the same method name is defined for the same class in
two different files?

Meanwhile, classes list ASF::Commitee and ASF::Person are constructed
from various sources.  But one thing you can count on: if you find a
given person or committee or whatever, and still have a handle for
that object, and try to find it again, you will get the same object.

Try, for example:

sebb = ASF::Person.find('sebb')
p sebb
ASF::Person.preload('cn')
p sebb

Keeping a handle on the object can therefore be very important for
performance reasons.  If you let it go, and the storage is garbage
collected for any reason, the next time you access that
person/committee/whatever it will need to go back out to LDAP.  One
fetch of every 'cn' is much more efficient that an individual fetch
for every person; and is much more efficient than multiple fetches for
every person.

That's why you will see code like the following:

people = ASF::Person.preload('cn', group.members)

... even if 'people' is never explicitly referenced by the code again,
keeping a handle on those objects will prevent them from being garbage
collected until the people variable itself goes out of scope.

- Sam Ruby

Reply via email to