CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

About "protected virtual void DataPortal_Fetch(object criteria)" in ReadOnlyListBase

rated by 0 users
Answered (Verified) This post has 1 verified answer | 2 Replies | 0 Followers

Not Ranked
9 Posts
foxhard posted on Sun, May 13 2012 11:40 PM

Hi,

I have see several examples of implementation of ReadOnlyList classes. But the fetch method is like this:

private void DataPortal_Fetch(SomeCriteriaClass criteria)

{...}

But, if inside ReadOnlyListBase there is the method: "protected virtual void DataPortal_Fetch(object criteria)" . Is there some performance issue if I use override method inside my inplementation like this:

protected override DataPortal_Fetch(object criteria)

     SomeCriteriaClass someCriteria = (SomeCriteriaClass)criteria;

}

 

Answered (Verified) Verified Answer

Top 10 Contributor
1,770 Posts
Answered (Verified) JonnyBee replied on Mon, May 14 2012 12:14 AM
Verified by foxhard

CSLA internally relies on reflection to make a dynamic call into the object.

So take f.ex a class that have several criteria classes:

private void DataPortal_Fetch(SomeCriteriaClass1 criteria)
{  ...   }

private void DataPortal_Fetch(SomeCriteriaClass2 criteria)
{  ...   }

private void DataPortal_Fetch(SomeCriteriaClass3 criteria)
{  ...   }

The DataPortal_Fetch all have a similar signature with one object as input.
Rather than having 3 Fetch methods we prefer to have on method and test for the actual criteria type.

protected override DataPortal_Fetch(object criteria)
{
     // Your code should check for the type of Criteria object.
}

That said, CSLA will check for

  • strongly typed methods first then
  • method with the correct number of parameter (and some fuzzy logic if finding multiple methods).
  • the default name 

So this is not so much about performance as for coding style.

Jonny Bekkum, Norway CslaContrib Coordinator

All Replies

Top 10 Contributor
1,770 Posts
Answered (Verified) JonnyBee replied on Mon, May 14 2012 12:14 AM
Verified by foxhard

CSLA internally relies on reflection to make a dynamic call into the object.

So take f.ex a class that have several criteria classes:

private void DataPortal_Fetch(SomeCriteriaClass1 criteria)
{  ...   }

private void DataPortal_Fetch(SomeCriteriaClass2 criteria)
{  ...   }

private void DataPortal_Fetch(SomeCriteriaClass3 criteria)
{  ...   }

The DataPortal_Fetch all have a similar signature with one object as input.
Rather than having 3 Fetch methods we prefer to have on method and test for the actual criteria type.

protected override DataPortal_Fetch(object criteria)
{
     // Your code should check for the type of Criteria object.
}

That said, CSLA will check for

  • strongly typed methods first then
  • method with the correct number of parameter (and some fuzzy logic if finding multiple methods).
  • the default name 

So this is not so much about performance as for coding style.

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
9 Posts
foxhard replied on Mon, May 14 2012 12:20 PM

Thanks Jonny

Page 1 of 1 (3 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems