By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,183 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,183 IT Pros & Developers. It's quick & easy.

silly questions for an expert in OOP

P: n/a
Hi everyone, i have currently got a classic asp web application and am
wanting to upgrade it to asp.net 2.0, and also take advantage of OOP.
Our current application is not using OOP so you can imagine how hard it
is too upgrade.

I have read documentation all over the net, but still have some
questions (if anyone has any good documentation, i would love to read
it!!). i should warn you the questions maybe stupid/easy but i just
need to confirm that answer, so i know i am thinking along the correct
lines, or wrong lines as it may be. lol

1. My web application has many users, but not all users have the same
connection string to connect to their database. In order to keep the
each layer (data, business, presentation) separate, how could i go
about this?? I do not really want to pass the connectstring down each
layer, do i??

2. In my database, we have a company which has many contacts (one to
many relationship).
I have a Company function called GetByCompanyID, which returns a
company object
and i have a Contact function called GetByContactID, which returns a
contact object.

If i want to get all the contacts at a company, how do i go about it?
I do not want to repeat code, i gather i would create a function like
GetContactsForCompany(id), which would extract the data from the
database and fill in a business object?

Once i have done that, do the child objects go into a collection class,
or should i reference them something like Company.Contacts.Item(x)?

3. I am trying to build the data access layer myself, as i really
dont want to some software doing it for me, so i know exactly how it
works etc. Does anyone know of a really good article, that also
explains about relationships and how to extract that data correctly?

I know that some of these questions really depend, on how the system is
setup, and maybe there is no right/wrong way, but i would really
appreicate your comments.

Cheers

Aug 14 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hello Nemisis,

N1. My web application has many users, but not all users have the
Nsame connection string to connect to their database. In order to
Nkeep the each layer (data, business, presentation) separate, how
Ncould i go about this?? I do not really want to pass the
Nconnectstring down each layer, do i??

How this implemented now?
Why users need to know each own connection string?

NI have a Company function called GetByCompanyID, which returns a
Ncompany object
Nand i have a Contact function called GetByContactID, which returns a
Ncontact object.
NIf i want to get all the contacts at a company, how do i go about it?
NI do not want to repeat code, i gather i would create a function like
NGetContactsForCompany(id), which would extract the data from the
Ndatabase and fill in a business object?

If your business requirements is not clear just right now the best approach
might have be only one method
that will get the params of script which result u want to get.

NOnce i have done that, do the child objects go into a collection
Nclass, or should i reference them something like
NCompany.Contacts.Item(x)?

It's up to you. Either the collection or DataSet/DataTable. First is more
flexible and fast, the second is a bit redundant and general.

I recomend to read this article http://msdn.microsoft.com/asp.net/de...CustEntCls.asp

N3. I am trying to build the data access layer myself, as i really
Ndont want to some software doing it for me, so i know exactly how it
Nworks etc. Does anyone know of a really good article, that also
Nexplains about relationships and how to extract that data correctly?

See there http://laflour.spaces.live.com/blog/cns!7575E2FFC19135B4!245.entry

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Aug 14 '06 #2

P: n/a

Michael Nemtsev wrote:
Hello Nemisis,

N1. My web application has many users, but not all users have the
Nsame connection string to connect to their database. In order to
Nkeep the each layer (data, business, presentation) separate, how
Ncould i go about this?? I do not really want to pass the
Nconnectstring down each layer, do i??

How this implemented now?
Why users need to know each own connection string?
Thanks for the advice and articles, i have read the microsoft articles
and i understand the concept alot better.

One question i still do have is about connection strings. Our users,
use different databases, but use the same web application, so as you
can gather each user at current has their connectionstring saved as a
session variable, so the correct database is used for that customer.

How would i go about this in my data layer, especially since i dont
want to pass any variables down tiers etc?? I dont really want to use
a session variable within the data layer, as my data tier maybe used in
windows applications in the future.

Aug 15 '06 #3

P: n/a
Hello Nemisis,

I'd recomend to incapsulate connection string (as i understand the login/pass
are too located on the client side)
on the side of web-services and set the user ID which will be assigned to
the specific connection string.

You can assign this ID to the several connection strings.

The idea is that users should know nothing about credentials, only admins
have to assign them to the desired resources/connections

NOne question i still do have is about connection strings. Our users,
Nuse different databases, but use the same web application, so as you
Ncan gather each user at current has their connectionstring saved as a
Nsession variable, so the correct database is used for that customer.
N>
NHow would i go about this in my data layer, especially since i dont
Nwant to pass any variables down tiers etc?? I dont really want to
Nuse a session variable within the data layer, as my data tier maybe
Nused in windows applications in the future.
N>
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Aug 15 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.