Fetching childs through Child Dataportal

Fetching childs through Child Dataportal

Old forum URL: forums.lhotka.net/forums/t/6611.aspx


amselem posted on Monday, March 16, 2009

I've upgraded to 3.6.1 and wanted to start using the child dataportal.

I've seen the ProjectTracker example and found that when the Project root is fetching the Resources BL, it's calling its shared friend factory method, then it calls Dataportal.FetchChild. I wonder if it's ok -or not- to call directly the child DP inside Root DP and bypass the shared method since it isn't doing anything special.

In Project.vb, DataPortal_Fetch method,  instead of

LoadProperty(Of ProjectResources)(ResourcesProperty, _
     ProjectResources.GetProjectResources(data.Assignments.ToArray))

I'd like to use this:

LoadProperty(Of ProjectResources)(ResourcesProperty, _
    Dataportal.FetchChild(
Of ProjectResources)(data.Assignments.ToArray))

I also missed a FieldManager.FetchChildren() method to call multiple child BL, just like the FieldManager.UpdateChildren pattern. Maybe this can be added to the framework if it makes sense.

Thanks in advance for your comments

ajj3085 replied on Tuesday, March 17, 2009

Technically it's ok, but it breaks encapsulation.  The idea is that the parent knows as little about it's child as possible.. including how it's created.

amselem replied on Tuesday, March 17, 2009

Thanks for your comments ajj3085

I don't see where it breaks encapsulation... I think that the parent should delegate to child DP the creation of the children, just like it delegates the update call. I don't see the point of having the child friend factory method now since we have child DP. In fact I think that the factory method was friend scoped for allowing the parent to call it, isn't that also breaking encapsulation?

Maybe I'm wrong but now I'm dropping all child factory methods in favour of the DP code, it saves some code and I think that the encapsulation is more o less the same.

 

Copyright (c) Marimer LLC