I need real help!

  • Thread starter Thread starter pcthug
  • Start date Start date
P

pcthug

Hi All,

I am creating multi-tier app in vb.net using visual studio .net.

I create a invoice.vb class file with properties, events and methods. This
also has a line item collection class (lineitem.vb & lineitems.vb). I create
a form (form1.frm) and write the corresponding code to initialize an invoice
object, there are textboxes on the form to display the data, an update and
load button. My data is stored in an access database.

Q. How should my objects interact with the database? eg. When the user
enters in values for the required properties etc and clicks update (we
already have an instance of the invoice object), the code behind calls the
set method of the corresponding properties in the invoice class etc.
Q. Is this where the connection should be made to update the database, if so
how?

or

Q. Should I have a data object also that is initialized when a invoice
object is and update commands are passed through when properties are set?

I hope this makes sense to someone! any help would be cool.

Cheers
 
In most scenarios, you see something like the following:

DAL - Data Access Layer:
Generic layer to access the database. Idea is you can quickly switch out
databases by having a DAL. For an easy method of setting this up, you can
use the Microsoft Data Access Application Block.

NOTE: There is an error in one of the FillDataSet() methods. The line is:
tableName += tableName + (index + 1).ToString();
should be:
tableName = "Table" + (index + 1).ToString();

Data Layer:
If you use strongly typed datasets, this is where you store them.

Business Layer:
Business objects. If a person changes data, you should have a dirty flag, or
similar, that allows you to fire an update event. There are two options
here. The first is to have the class have CRUD methods. The second is a
helper class to fill the various business objects. There is also a unique
idea from Paul Sherriff, which I happen to like, that has the business
objects derive from DataSet. You can then use the DataAdapter that fills the
strongly typed DataSet call Update() to update the business object. You will
find that some, like Rockford Lhotka prefer more traditional business
objects. If you wish to head this direction, his book is well worth the
read.

UI layer:
Fairly self-explanatory.

Hope this helps as general guidelines.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Cool, this is really interesting and a good start. Do you have any links to
online content, tutorials that are .net specific.

Thanks heaps
 
If you like the Paul Sherriff method, here is a link to a webcast. You will
have to install the software to run it (not spyware, so it is okay), but it
is a great presentation:

http://www.microsoft.com/usa/webcasts/ondemand/1791.asp

This presentation shows the DAL, Data (strongly typed datasets) and Business
layer (derived from DataSet). You can download the sample code from
www.pdsa.com.

There are some things I am not completely sure of in this architecture, but
the main benefit is I can send anyone to this presentation to understand it.
That is worth quite a bit in maintainability.

Microsoft also has plenty of 'best practices' eBooks at
http://msdn.microsoft.com/architecture - go to the "Patterns and Practices"
section.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Cheers Gregory. I went to MS last night and read the Data Application Block
documentation and a few other bits that returned on the search. I have
finally figured out where it is all going. I have been programming for a wee
while now and have always been unsure of the correct methodology and it
seems I was along the right lines as several DAL's I have written implement
the same way as the Data App Block. This has been a major stumbling block
for me and a few others so this helps alot. I really like the sound of the
Paul Sherrif method, and I need some source code to show the implementation
of bus objects, so I will go check it out.

Thanks alot
Jodie Rapson
 
Jodie,

Rocky's book has rudimentary WinForms examples. It shows how to use CSLA in
WinForms. The book is worth a read just to understand scalable architectures
better.

Kathleen
 
Like I said, I am not 100% sure of everything he is doing, but it is a sound
and easy to train architecture.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
I believe the examples were embedded SQL, but moving to stored procedures is
a fairly simple matter. The main difference is the addition of Parameters to
your command object.

To simplify, in my addition to the architecture, I add the Data App Block
(free download from MS) and use it for the generic access part of the data
layer.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 
Back
Top