Need advice on working with coarse-grained objects

B

BillG

I am used to dealing with recordsets and I am using a coarse-grained object
and need to know if I am doing it correctly.

I have a class named Activity which represents an event being planned (golf
outing, dinner dance etc.). The Activity hold a list of Registrations which
represents some company or individual reserving a spot at the activity. The
Registration class holds a list of Attendees which represents the
individuals being registrered for the event. when the Activity is loaded
into memory to be displayed in a form, the activity object data access class
loads the registrations for that activity and the Registration DAL loads the
Attendees into memory. Once the activity is loaded into memory no more data
access occurs. As new registrations are more or new attendees are added,
they are added in memory to the lists of items. When the activity is saved,
the activity writes the registrations back to the table and the registration
writes the attendees back to its table. For an update I delete and insert
all the registrations and attendees for that activity rather than worrying
about updating them.

Is this the proper way to handle a coarse grained object?

Bill
 
B

Bob Powell [MVP]

I wonder why you've chosen a business object model for something that is so
clearly representable using some form of database / datatable.

Perhaps you should reconsider the data model entirely.

To deal with the question in more general terms, business objects in .NET
should implement change notification such as INotifyPropertyChanged. Data
binding can be used to tie the data to a UI and the BindingList<T>
collection class used to store lists of such objects so that list change
notification can be used to update list view and grid objects.

My general philosophy would be to change as little as possible in any one
operation because, as the data grows, you may find that the complexity of
adding and removing many objects for a simple operation becomes a severe
performance bottleneck.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top