473,700 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Unfortunatel y 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 1705
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 MyDataAccessObj ect

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

End Module

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

I also use stored procs.

Compartmentaliz ation 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
1394
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 table , insert , update , delete ) and each user have his own space ( users not able to see others data and a limit say of 2 MB) . The most obvious solution is to create ( if I have 100 users ) , 100 login account ( SQL Server Accounts ) , then...
10
2113
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 with it. I am consulting on a new project. Originally I was going to get data dumped to me from an external system, and import the needed data once a week into a normalized design that I had created. I knew what my fields were going to be,...
15
2137
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. DB #1 = StudentDB DB #2 = TestResulstsDB Why are there 2 dbs? I do not know - but that is one of the tings that we will be changing. Combining all of the data into one database.
5
1520
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 problem is design structure. Where to begin, etc. I see that everyone recommends The Access 97 Developer's Handbook (I am looking for a Access 97 book), but is that going to be too advanced in terms of getting a db off the ground? I am thinking I...
10
2131
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 shouldn't be here). I have two design questions: 1. what is the correct (or best) way to include database queries into the code if you plan on
29
3569
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 one data field - but i'm not sure) :-) Background info:
5
1978
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 better, I would like to see what others thinks would be the better approach, or even suggest a different approach if you can think of any other. Lets suppose I have 1000 users. and each user will need to store information on 9 different places. But...
23
2434
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 due to the fact that the "designer" they hired had an unfortunate ability to tink around with a program far beyond her reach. She had no concept of any of the principles of database design, so what i'm left with is a junkpile. The only reason I...
3
2481
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 one etc.....),building ER diagrams,proper usage of ER diagrams in our database(Primary key foreign key relations),designing small modules,relating tables and everything that relates about database design....Coz I think database design is the...
22
3657
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 than just family and friends. Either way, I'm planning on this site blowing up once I have enough of a feature set, so I'm concerned about performance and scalability in the long run. I've worked for a software company, but I've never...
0
8714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8958
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7797
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6557
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2021
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.