List ObjectsOld forum URL: forums.lhotka.net/forums/t/5247.aspx
whelzer posted on Friday, August 15, 2008Many thanks for help recived so far;
I've a recurring theme in my trading app which we're converting from VB6.....
I've a requirement to use a list of currencies mostly for populatig list and combo boxes.
No big deal (CcyInfo and CcyList), the issue is I've a huge number of types of Ccy Lists to get,
Eg All Ccys
Ccys by trade type
Ccys used in last xxx days
Ccys traded by client in certain way etc, etc...
SPs are used throughout to get the data from DB
I think I've 2 choices:
1) have a number of Ccy List objects ie CcyListAll, CcyListActive, CcyListByClient, etc
2) have one CcyList object and overload factory method GetCcyList with an enum parameter and other criteria.
eg Public Shared Function GetCcyList(ByVal MyValue As CcyListEnum) As CcyList
Public Shared Function GetCcyList(ByVal MyValue As CcyListEnum, byval TradeType as integer) As CcyList
Public Shared Function GetCcyList(ByVal MyValue As CcyListEnum, byval ClientId as integer) as CcyList
In Data Access method DataPortal_Fetch(ByVal criteria As Criteria), select case the enum and call the relevant SP.
Any pointers much appreciated.
Fintanv replied on Friday, August 15, 2008
FWIW I use a similar strategy to what you propose in choice 2. Much less confusion for the person using the API.
JoeFallon1 replied on Friday, August 15, 2008
I also use #2. I do not see the need to have different objects that all have the same internal structure and methods. It is just easier to have many factory methods and then pick a branch in the DP_Fetch based on method name or some other criteria. This branch simply returns the SQL or SP and then the rest of the fetch is the same for all result sets.
JonnyBee replied on Sunday, August 17, 2008And a possible choice #3:
Create functions such as
Public Shared Function GetCcyListAll()
Public Shared Function GetCcyListByTradeType(ByVal TradeType integer)
Then create a separate (private class) Criteria object for each different criteria sets. Ex
And finally create the adjoining Fetch functions in your BO's:
DataPortal_Fetch(ByVal criteria As AllCriteria)
DataPortal_Fetch(ByVal criteria as TradeTypeCriteria)
That way you will get a very clean implementation - a little more criteria classes - separate DataPortal_Fetch methods (and you can still have a common function that reads the values form a DataReader providing all SO's return the same resultset)
whelzer replied on Sunday, August 17, 2008Excellant. Thanks for the replies.
Copyright (c) Marimer LLC