Page 1 of 1

What would you refer to this object as

Posted: Thu Nov 27, 2008 11:25 pm
by alex.barylski
EDIT| Just occured to me...I'm looking for a name to give this object so the accessor method makes more sense. Association is what the relationship is...but ideally I"m looking for a definition or term to describe the methods purpose, such like:

Code: Select all

 
getGroupListHelper()
getGroupListObject()
getGroupListModel() // Perhaps the best choice? Unless you have a cooler name <!-- s:P --><img src=\"{SMILIES_PATH}/icon_razz.gif\" alt=\":P\" title=\"Razz\" /><!-- s:P -->
 
I have two models each of which maps a separate database table.

One is for holding records and the other table is for group associations which record can have. It's a one to many relationship, where one record can have multiple groups.

The models map these two tables and the association model is never to be used independently but strictly through the main objects API.

If you want to add a group to a specifc record you would access the secondary object with something like:

Code: Select all

$model = new Main_Model();
$model->getSecondaryModel()->createGroup($name);
In C++ I might define the secondary class as a private and make it a friend class of primary model so only it ever had access to this model object. Alternatively after a while, if it was clear it would never be called externally, I would implement the model as a nested private class, of course neither are available in PHP. :(

What or how would you define this secondary object according to pattern terminology? I personally wouldn't consider it a helper object as helpers I tend to think of as generic objects which are more reusable as opposed to being bound to a specific model through composition.

The secondary model is always used as a composite in the primary and it's access is restricted to accessors/mutators.

I Googled broker quickly as it seemed to make sense however (according to M$) it's more for distributed systems, which this is not nessecarily so.

Perhaps an association object? :P

Cheers,
Alex

Re: What would you refer to this object as

Posted: Fri Nov 28, 2008 9:14 am
by josh
Delegate object?

Re: What would you refer to this object as

Posted: Fri Nov 28, 2008 4:00 pm
by Christopher
PCSpectra wrote:One is for holding records and the other table is for group associations which record can have. It's a one to many relationship, where one record can have multiple groups.

Perhaps an association object?
Seems like "getAssociationGroups" from how you have described it.

Re: What would you refer to this object as

Posted: Sat Nov 29, 2008 7:30 pm
by alex.barylski
I did have exactly that at one point...the problem is...

The method is actually returning a reference to one of it's own objects composites. The object is of type "Model" so while it's returning group associations as a single array...actually you know what...maybe it isn't I can't say for sure without peaking at the code...

That is actually a important point...

If it's returning an array of group associations using the secondary model and providing a facade interface...then your suggestion is the way to go...however if I am returning the object reference to the model...and then required to call it's lists method...then I would want to include that "Model" in the method name somehow.

I think you may have just lead me to better understand the problem and perhaps more importantly the solution. :P

Cheers,
Alex