Does it make any sense to add the RunLocal attribute to a Child BO?
I am thinking of the case where the UI asks the collection to add a child. The collection may call the Shared Method which calls DataPortal.Create to load default values. In that case, you force the call thru the local dataportal and avoid the network transport hit.
A similar question - if a Root BO is marked with RunLocal and it fetches child BOs - would they RunLocal even if they were not marked as such?
Joe
Rocky,
I am not talking about child persistence. I am talking about child creation.
Page 369 of the VB book shows the diagram of what I mean. Note that DataPortal_Create is called and the child object is sent to the server to load its default values. So my question is would the RunLocal attribute be a good thing to add to the child DataPortal_Create method if I know the default values are not coming from the DB? This assumes the Constructor is essentially empty (just has the call to MarkAsChild) and that the Shared Factory method calls DataPortal.Create.
Friend Shared Function NewChild() As Child
Return DataPortal.Create(Of Child)()
End Function
<RunLocal()> _
Protected Overrides Sub DataPortal_Create()
SetDefaults()
ValidationRules.CheckRules()
End Sub
By setting the defaults in DP_Create I can call an Overridable method. One of the FxCop rules is to not call Overridable methods from a Constructor because the fields in the next level have not been initialized yet. By letting the DataPortal create the instance we know that all fields have been initialized and calling an Overridaable method at this point is not "dangerous".
Joe
From: JoeFallon1 [mailto:cslanet@lhotka.net]
Sent: Thursday, October 05, 2006 7:09 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] RunLocalRocky,
I am not talking about child persistence. I am talking about child creation.
Page 369 of the VB book shows the diagram of what I mean. Note that DataPortal_Create is called and the child object is sent to the server to load its default values. So my question is would the RunLocal attribute be a good thing to add to the child DataPortal_Create method if I know the default values are not coming from the DB? This assumes the Constructor is essentially empty (just has the call to MarkAsChild) and that the Shared Factory method calls DataPortal.Create.
Friend Shared Function NewChild() As Child
Return DataPortal.Create(Of Child)()
End Function<RunLocal()> _
Protected Overrides Sub DataPortal_Create()
SetDefaults()
ValidationRules.CheckRules()
End SubBy setting the defaults in DP_Create I can call an Overridable method. One of the FxCop rules is to not call Overridable methods from a Constructor because the fields in the next level have not been initialized yet. By letting the DataPortal create the instance we know that all fields have been initialized and calling an Overridaable method at this point is not "dangerous".
Joe
Ok.
Thanks!
We agree. <g>
Joe
Copyright (c) Marimer LLC