
Originally Posted by
kyberfabrikken
The obvious solution is to use recursion. I suspect, that you know this already, and that you're weary of using that approach, because you fear the performance overhead? If you're going to maintain a large object graph, and do a lot of query-by-id, the overhead may be substantial. However, before worrying about this, you have to ask yourself the same question as always, when it comes to performance problems: Is it a real problem or an imagined one? I would suggest, that you implement using recursion, and then later measure if you have a bottleneck or not. If you do, a solution could be to use a hashmap of id => object. This could easily be applied at that point, so no need to spend time on it yet.
Well the number of objects won't be too big I imagine, a safe guess would be under 4-500 so that shouldn't be too huge (I think)
I am just pondering how the function would work in the FormEditor class
say I wanted to retrieve a member object and set it's id attribute
Code:
// pseudocode
function updateMember($sDimensionID, $sLevelID, $sMemberID, $sNewID)
{
$oDimension = $this->oForm->getDimension($sDimensionID);
$oLevel = $oDimension->getLevel($sLevelID);
$oMember = $oLevel->getMember($sMemberID);
$oMember->setAttribute('id', $sNewID);
}
Is this approach right or is there another way I completely missed?
Bookmarks