dataset and custom classes

  • Thread starter Thread starter glenn
  • Start date Start date
G

glenn

I have written as a test a customer class that has all the necessary field
handling and formatting routines in it that I need. I have dataaccess class
that controls reading and writing the class into the database. However, I
am now getting to the user interface layer and a little confused as to where
to head next.

What I would like to do is somehow attach my class to a dataset or something
that would make it easy to read and write data into my classes without the
programming having to manually write get and set routines for each and every
field on the form.

Can anyone offer any suggestions as to the best way to handle this? I want
to try to keep my business layer as far away from the UI as possible but
want to provide easy methods for the UI programmers to use when they are
attaching to my classes.

Thanks,

glenn
 
Hi,

What do you mean by field handling and formatting?

Formatting, as a general rule, should be a responsibility of the UI layer,
but not of a business entity object. Handling can mean different things - if
you assume enforcing certain business rules, the business entity object is
the right place.

In general, a kind of rule of thumb I've seen in the Microsoft Patterns and
Practices is - if your business object is merely a data holder, use a typed
DataSet instead. Otherwise, if you encapsulate business rules, validations
or things like that, use a class.

Finally, if your business entity is a custom class, you still can use
databinding. I am not sure this type of databinding is supported in the
Windows Forms designer (probably it is provided you add proper attributes to
the business class' public properties), even if it is not - you can create a
number of DataBinding objects manually to link the class properties to the
controls on the form.

Hope this clarifies things a bit.
 
Back
Top