Paul Hill wrote: > Hi All, > > I've been thinking about n-tier design... > > I have a business class. This class has properties for all the > underlying database fields. > There's a method called GetByID() that fetches 1 record based on the > PK for that table. > > Great. I can update the properties and call Save() which sends an > update to the SQL table. > > But suppose I want to search for a range of records. > So I have a method called GetBySurname() that can return multiple > records. This method returns a Recordset/array/SqlDataReader etc. > > But this doesn't really 'fit'. The business object represents 1 record. > > What's a nice solution? > One way would be to implement SkipNext() & Eof() methods that let you > move through the data, but sometimes I want a Recordset if I'm passing > the data to a grid. > > Thoughts? >
Anthony Testi had once thought as you did, but you don't know the power of the Force! Er, oh, wait...wrong storyline. Seriously though, Anthony struggled with how to represent this in the OOP-ist fashion, citing like you did that it's one record. No, it doesn't have to be that way. Simply recognize the business object as the mediator between the UI and DataObject in that it's responsible for chaining along requests from the UI to the DataObject and passing back messaging and cursors from the DataObj to the UI. It also functions to validate data, or your business rules, thus the name. You don't want to lose the power of the VFP cursors and as such you should continue to create cursors in the DataObject and let me be seen by the BizObject and UI. You then work on those cursors (be it single record or multiple records) in the UI and then use the BizObject to validate your data, and your DataObject to save the changes. This approach is a "logical" n-tier design that has a transparent layer between each tier. This doesn't work if you need a physical n-tier design, there the tiers are running in different processes. I presented the topic of n-tier design at FoxForward 2K6 and 2K7, and made my slides and code available on Ed's site here: http://leafe.com/forum/viewtopic.php?t=1860&sid=6f4da70d4ad882270d7906c178ca7a1e and http://leafe.com/dls/vfp It's a great topic, so ask away! Many here could lend good help to you. --Michael _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/profox OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED] ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.

