473,772 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best practices accessing data?

Hi.

I'm reading and reading, testing and testing, trying to figure out how
to do things, how to do things according to best practises and how to
do things in the best object oriented way.

So... Best practises, in good object oriented fashion: how do I do it.

I'm thinking making classes for data access. An Example that ALL books
do - customer - and orders. So I'm thinking: Making a customer class
and a orders class. The customer class has methods for accessing the
customer table (or datasource of some kind) and it also has
functionality to get the related orders.

I can use generic factoring in the class, so this does NOT make my code
database specific.

Secondly I can put a ObectDataSource on my form, point it to my class,
tell it what functions will fill the dataset etc. (btw: do I need one
separate datasource for each of the functions I wanna point to in the
class... ?)

Then I connect the gridview to the object datasource to publish my data
to the user.

Well, does this sound like I'm on the right track.. ?
You wouldn't happen to have some code on how you do it.... ?

I will greatly appreciate a discussion about this!

Thanx,
Fritjolf

Aug 24 '06 #1
1 1413
I would take a look at an OR mapper such as nhibernate, wilson or, lblgen,
etc.

What you are describing sounds a bit like active record ...

I might also suggest looking at the repository pattern where you seperate
the concern of managing the objects out of the bsiness object and into its
own object. As you said you can hack your way into database independence but
what if as an example you now need to read some customers from a webservice
or from a text file .. the customer class will quickly get crowded with
accessor methods.

There is a great example of customer/order using a repository in Jimmy
Nilsson's Applying Domain Driven Design and Patterns.

Cheers,

Greg

"DelphiLove r" <Mo************ *@edb.comwrote in message
news:11******** **************@ i3g2000cwc.goog legroups.com...
Hi.

I'm reading and reading, testing and testing, trying to figure out how
to do things, how to do things according to best practises and how to
do things in the best object oriented way.

So... Best practises, in good object oriented fashion: how do I do it.

I'm thinking making classes for data access. An Example that ALL books
do - customer - and orders. So I'm thinking: Making a customer class
and a orders class. The customer class has methods for accessing the
customer table (or datasource of some kind) and it also has
functionality to get the related orders.

I can use generic factoring in the class, so this does NOT make my code
database specific.

Secondly I can put a ObectDataSource on my form, point it to my class,
tell it what functions will fill the dataset etc. (btw: do I need one
separate datasource for each of the functions I wanna point to in the
class... ?)

Then I connect the gridview to the object datasource to publish my data
to the user.

Well, does this sound like I'm on the right track.. ?
You wouldn't happen to have some code on how you do it.... ?

I will greatly appreciate a discussion about this!

Thanx,
Fritjolf

Aug 25 '06 #2

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

Similar topics

18
9195
by: Lorenzo Bolognini | last post by:
Hi all, i am an ASP developer with 1,5+ years experience. After sneaking around the ASP Classic world for a bit i became a bit dissatisfied of my ASP code practices so i'd like to have some advice from the advanced/pro users... some advice that would help me to grow up! I know that many (if not all) the stuff that was a hassle in ASP 3 has been corrected in ASP.NET/VS.NET (which i'm studying) but ASP 3 will still be around for a long...
136
9456
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
2
2722
by: Duncan Welch | last post by:
Good morning, I have a classic ASP app that I'm converting to .NET. In the existing app when accessing infrequntly changed data, it reads a database once a day, and saves the results in an application variable. I'm trying to replicate this in .NET, but I'm using a data access layer (DAL) that's in a seperate project. Obviously, the DAL can't see the application variables. I was thinking of passing the application state in the...
2
2003
by: G. Dean Blake | last post by:
We currently distribute a web application to serveral servers for a customer. We have been putting the connection string in our web.config file under <appSettings> <add key="dbconn.Connectionstring" value="workstation id=server025....... etc. When we deploy the application we have to change the workstation id and source parameters to name the server where the database will be. We tried to simply specify localhost however VS.NET could...
1
3889
by: jmhmaine | last post by:
I've used the WebClient class on a few projects but I wanted to know if anyone could point to the good resource for Best Practices with this object. The two things I haven't seen in sample code are: 1. How to retrieve connection error messages, such as a DNS resolution error or connection dropped errors. 2. Should I use the Dispose or Finalize methods to destroy the object when I done? I assume that the object uses unmanaged code at some...
10
3482
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read somewhere that each folder under the "web site" is compiled in separate assembly. I however, did not find that the "web site" creation in vs.net 2005 created any AssemblyInfo.cs file.
4
2630
by: Collin Peters | last post by:
I have searched the Internet... but haven't found much relating to this. I am wondering on what the best practices are for migrating a developmemnt database to a release database. Here is the simplest example of my situation (real world would be more complex). Say you have two versions of your application. A release version and a development version. After a month of developing you are ready to release a new version. There have...
3
2245
by: John Dalberg | last post by:
I am looking for an ASP.NET application on CodePlex which exemplifies best practices for the following: - Use of interfaces - Seperation of the UI, business and data tiers - Data Tier that uses Enterprise Libraries data layer (if possible) - Use of providers (if possible) - use of factories (if possible) - use of caching - Session management
2
6479
by: olafinsbraaten | last post by:
I am using column-level encryption (ENCRYPT_CHAR, DECRYPT_CHAR) to protect selected columns in DB2 LUW v.9.1 and v.9.5 on Linux. The ultimate goal is to support the requirements put forward in Payment Card Industry Data Security Standard (PCI DSS) which states: "Protect stored cardholder data anywhere it is stored". The encryption functions above requires a password to be set for each db2 session (SET ENCRYPTION PASSWORD =...
0
9621
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
9454
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
10264
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
10039
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,...
1
7461
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
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4009
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
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
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.