silly questions for an expert in OOP

N

Nemisis

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
 
M

Michael Nemtsev

Hello Nemisis,

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

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

N> I have a Company function called GetByCompanyID, which returns a
N> company object
N> and i have a Contact function called GetByContactID, which returns a
N> contact object.
N> If i want to get all the contacts at a company, how do i go about it?
N> I do not want to repeat code, i gather i would create a function like
N> GetContactsForCompany(id), which would extract the data from the
N> database 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.

N> Once i have done that, do the child objects go into a collection
N> class, or should i reference them something like
N> Company.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/default.aspx?pull=/library/en-us/dnaspp/html/CustEntCls.asp

N> 3. I am trying to build the data access layer myself, as i really
N> dont want to some software doing it for me, so i know exactly how it
N> works etc. Does anyone know of a really good article, that also
N> explains 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
 
N

Nemisis

Michael said:
Hello Nemisis,

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

Michael Nemtsev

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

N> One question i still do have is about connection strings. Our users,
N> use different databases, but use the same web application, so as you
N> can gather each user at current has their connectionstring saved as a
N> session variable, so the correct database is used for that customer.
N>
N> How would i go about this in my data layer, especially since i dont
N> want to pass any variables down tiers etc?? I dont really want to
N> use a session variable within the data layer, as my data tier maybe
N> used 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top