473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

OOP design in .NET with databases

Check out the Data Access Objects (DAO) design pattern
proposed by E. Gamma in the Go4 book.
-----Original Message-----
I am struggling with a design issue using .NET.
Let's say we have an object model and now want to code it. In the objectmodel is an Access database. Most programmers would start a new project andslap a connection and data adapter object on a form and start coding.Unfortunately this could not possibly fit any object model ever conceived.I am trying to determine best practices with this issue. My suggestion isthe following:

Encapsulate the database into a class. This class would be an aggregate ofother objects such as Customer, Company, etc. All needed collections such ascustomer names would be other objects. There would be methods in the classfor accessing the database and filling the properties as needed.
Does anyone have comments on this? All the books I have read on ADO.NETslap connections and data adapters onto the main form. This doesn't seem tobe very scalable. Is this the way people are really building .NETapplications?

Regards
Jerry
.

Jul 19 '05 #1
1 1693
Wizards... FAH!

I've also written my own Data Access Block that the app's data access
object (DAO) inherits. It handles connections and common SQL method
calls to eliminate redundant coding.

The project's data access class contains all the app's SQL and is
exposed through a global property that all the other object classes in
the project can see/use.

Module AppCommon

Private m_objDA As MyDataAccessObject

Friend ReadOnly Property g_DAO() As MyDataAccessObject
Get
If m_objDA Is Nothing Then m_objDA = New MyDataAccessObject()
Return m_objDA
End Get
End Property

End Module

So from anywhere in my *.dll it's simply g_DAO.FetchMyResults or
g_DAO.cn to get to the database.

I also use stored procs.

Compartmentalization is a good thing.
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: db_happy | last post by:
Hi I need some design info. Say that I need to create an educational lab for databases with SQL Server. I need all the users to be able to execute common SQL commands ( create - alter – drop...
10
by: BlueDolphin | last post by:
I'm not sure if this is a question or more of a rant... but I'm looking for some input on this from other developers out there. How often has the following happened to you and how have you dealt...
15
by: kimi | last post by:
I have just started working on a project that is partially complete. It is an application that is using access to store test results. The test results are being stored in two Access 2000 databases....
5
by: Aya9877 | last post by:
Alright, I have no idea what level book I need. I have a basic/decent background in coding. I am advanced in query building. I have a decent understanding of Visual Basic and some VBA. My...
10
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
5
by: jensenat | last post by:
Hi, I am in the process of develop a multiuser application. I started today with the database design and I am not sure how to proceed, I have two ideas, but since I am not sure which one will be...
23
by: JohnH | last post by:
I'm just recently come to work for an auto brokerage firm. My position involves performing mysterious rites, rituals and magick in order to get information out of their access database. This is...
3
by: vicky | last post by:
Hi All, Can u please suggest me some books for relational database design or database modelling(Knowledgeable yet simple) i.e. from which we could learn database relationships(one to many,many to...
22
by: Jesse Burns | last post by:
I'm about to start working on my first large scale site (in my opinion) that will hopefully have 1000+ users a day. ok, this isn't on the google/facebook scale, but it's going to be have more hits...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.