Re: n-tier best practices

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Andrew Faust (afaust_at_aradymeDOTcom)
Date: 09/14/04


Date: Tue, 14 Sep 2004 11:22:33 -0600

You could have a function of your data class to retrieve the data
set.

"rodchar" <rodchar@discussions.microsoft.com> wrote in message
news:006E609B-539D-4E95-926C-373400529D6A@microsoft.com...
> If I create a business object how would I expose the dataset,
> like to use in
> a datagrid?
>
> "Andrew Faust" wrote:
>
>>
>> "rodchar" <rodchar@discussions.microsoft.com> wrote in message
>> news:B00106D8-5731-4AAD-944B-0AFABBBD38AB@microsoft.com...
>> > The dataset I'm referring to lives in the UI on Form1. What
>> > I'm
>> > wondering is
>> > if, let's say, you have form1 that shows a collection of
>> > parent
>> > records. You
>> > click on one and it takes you to form2 to show the details
>> > of
>> > that parent.
>> > Now, let's say from form2 you can open form3 to display the
>> > chidlren rows.
>> > And then, the user clicks on the collection to view the
>> > child
>> > details on
>> > form4.
>> >
>> > How would I persist the dataset, especially if you're going
>> > back and forth
>> > doing updates between form3 and form4?
>>
>>
>> > My idea, which I'm not sure is a good practice or not is to
>> > pass the
>> > dataset, which lives in form1, byRef between the 4 forms. Or
>> > is
>> > there a
>> > better way?
>>
>> Ok. That gives a bit better clarification. First thing you
>> will
>> usually want to do is to seperate the presentation layer
>> (forms)
>> from the data layer. Don't have the forms themselves doing the
>> data retrieval and updates. Instead create a class that
>> handles
>> all the data operations. Then you could be passing a reference
>> to
>> this class around to all the different forms. This way if you
>> make a change to the data class, then when you refresh your
>> view
>> on the other forms, the updates will appear, because they are
>> referencing the same object.
>>
>> If changes need to be made to your dataset that you are
>> passing
>> around, then I probably wouldn't pass just the plain dataset.
>> I
>> would pass a class which handles all data operations, then let
>> that class make any changes necessary. This way if you ever
>> need
>> to change some crucial pieces about how the data is stored or
>> handled, you can make the changes just in the one class,
>> rather
>> than in all classes that use it.
>>
>> If all these forms are not changing the data, but rather for
>> display only, then I would just go ahead and pass the data
>> set.
>>
>> Hope this helps,
>>
>> Andrew Faust
>>
>>
>>



Relevant Pages

  • Re: n-tier best practices
    ... If I create a business object how would I expose the dataset, ... "Andrew Faust" wrote: ... Then you could be passing a reference to ...
    (microsoft.public.dotnet.general)
  • Re: n-tier best practices
    ... Take another instance if you will, 2 forms that share a business object. ... I can pass a datarow from form1 to form2, and on form2 bind the row to the ... Then you could be passing a reference to ...
    (microsoft.public.dotnet.general)
  • Object References - got a blackout
    ... I'm calling a function, passing the reference of a ... business object for editing. ... object itself to the reference. ... public static bool EditMyObject(ref MyObject o) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: In-memory "Lookup" tables
    ... > At program start I want to retrieve a DB reference table into memory ... Reference table contents are: ... > Code: String; ... > What are the search/retrieval/destruction design considerations I ...
    (alt.comp.lang.borland-delphi)
  • Re: Retrieving child objects, and when
    ... The ContactDataService, for instance, could either return the data to a business object or it can act as a business object factory, ... I prefer using the service to retrieve data and have a business object, e.g. Contact, make the calls to the ... the database using my retrieve function within my ContactDataService, ...
    (microsoft.public.dotnet.general)