473,379 Members | 1,335 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,379 software developers and data experts.

Using Relational-Databases in Object Oriented design

I need a good design (pattern?) for working with persistantobjects.

This is what has been bothering me, I'm on 3'rd year inuniversity learning computer science, and I am now working on amedium-sized project involving persistant objects resting in arelational database. I'm developing it in .Net using C#. But i'mhaving problems persuing true object orientated design in thesekind of programs.

Basicly, what I used to do all the time, was to make my own SQLclass which would function as a wrapper for the ADO layer, Suchas DoCommand(string query), which I would use in my applicationclasses to work with Sql.

The problem with this is that now the Application Classes are theones creating Sql statements for the database and directlycommunicating with it, which goas against many OO principles.

So what I think of doing (and my teacher suggested me to do), isto have a Sql class handle all the database transaction, andequip it with methods that recieve application models, fillsthem up (or saves them) etc.

Ok, that would fix some areas, but brings its own issues. F.ex.this class would get pretty sizey, handling all thosetransactions (ofcourse I could make a Sql class tree, delegatingit a bit, or (as I saw alsewhere) make Data-classes for everypersistant class that handles it).

But the biggest issue with it, and this is my current problem, isthat it would require all members in the class to haveread/write access (so they can't be read-only). This, ofcoursegoes against all sorts of OO principles, and in my cases, I needalot of my members (which still are persistent) to be read-only(it's a .dll).

So... what can I do? What would be the best way to solve thisissues with OO-principles in mind?

~ Eric Nilsson ~

ps. I tried searching the web without much success (all keywordsare highly common), but if someone knows a article about this,then please link me.

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>f5R03hPlcUuhnDsxUmjT2Q==</Id>
Jul 21 '05 #1
2 1299
Eric,

The first thing I would look for is ADONET. That is built with OOP in mind.

The newsgroup for that is
Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

I hope this helps,

Cor
Jul 21 '05 #2
I have encountered just the problem I think you are dealing with here. I used
the ADO.NET dataset in the first release of a fiarly large enterprise
application. The choice was made more on a whim and a hope of meeting the
deadline rather than than as the result of a good brainstorming session. I
have found that creating my own wrapper classes for data (Order, Patient,
Physician, Encounter, OrderItem) is much better than a strongly typed
dataset. Simply put, all named objects expose much more functionality than a
VS-generated strongly typed dataset can provide. My final solution was to
create a custom wrapper for a typed dataset. And yes, there is alot of code
dealing with database access including concurrency.

"Cor Ligthert" wrote:
Eric,

The first thing I would look for is ADONET. That is built with OOP in mind.

The newsgroup for that is
Adonet
news://msnews.microsoft.com/microsof...amework.adonet

Web interface:
http://communities2.microsoft.com/co...amework.adonet

I hope this helps,

Cor

Jul 21 '05 #3

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

Similar topics

7
by: Rolf Hemmerling | last post by:
Hello ! Beginner's question: What ist the easiest way to store and save objects in a file generated by a C++ program, by using the "standard C++ library" and/or "Standard Template Library (...
18
by: comcast | last post by:
Hello all, I am developing an interface system for an application I was written. This interface will connect to other system to share information. I would like to use xml and xsl to generically...
2
by: Ramakant | last post by:
hi i am new at this...whats the better way to read xml files..create a dataset and read them using xml only for validation ... or use xmlreader to validate and read them? thanks in advance
17
by: Bruce Jin | last post by:
I wonder how many people are using db2 on Windows? I know db2 is native to AS400 which has about 800,000 installations. Thanks!
49
by: raju | last post by:
hi can we compare two integers without using relational operators (== != < <= > >=) thanks rajesh s
14
by: AliceB.Toklas | last post by:
In my Absolute Beginner's Guide to C book by Greg Perry where it is instruction how relational operators work it gives the following example: int i = 5; so the following statement is true: ...
2
by: Vadim Tropashko | last post by:
http://vadimtropashko.wordpress.com/why-relational-division-is-so-uncommon/
0
by: steve | last post by:
If you think you can easily translate most relational division problems to sql you should write a book. If your not even sure what relational division even is or how it can do done in a sane way...
24
by: sonos | last post by:
Hi, I am working on a program to archive data to disk. At what point is it best to use a relational database like MySQL as the backend instead of a C program alone? Thanks to any and all...
10
by: nayden | last post by:
I started playing with python a few weeks ago after a number of years of perl programming and I can say that my first impression is, unsurprisingly, quite positive. ;) The reason I am writing here...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?

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.