T
Tarun Mistry
Hi all, I have posted this in both the c# and asp.net groups as it applies
to both (apologies if it breaks some group rules).
I am making a web app in asp.net using c#. This is the first fully OO
application I will be making, also my first .NET application, so im looking
for any help and guidance.
Ok, my problems are todo with object and database abstraction, what should i
do.
I have defined certain objects my system will need, they are all linked.
Lets say these are
Patient --- Sample --- Sas
An Sas contains a Sample and a Sample contains a Patient. A patient can
exist on its own however a Sample needs a valid patient and an Sas needs a
valid sample.
At the database level i simply store 3 tables, one for each of the classes.
However, what is the procedure for loading my data back into objects before
I use them? I know I can make a static method within the class that loads
data, creates an object and returns it (although I was told this wasnt good)
or to use Data Access Objects (DAO)s as helper classes for my main classes
that do this work, again a good idea but i cant see it providing a solution
to one of my problems, see 2 below.
A few scenarios that are valid within the system:
1) I simply want to search the patients within the system. I could search by
patient parameters such as name and patientid. Will the patient class need
to contain code that performs this SQL query and returns an array of patient
objects, alternatively do I use a separate DAO (Database Access Object ) to
perform the patient queries? Now I need 2 classes to handle my patients (and
potentially 2 for Samples and 2 for Sas's etc etc).
2) I may want to search for all the samples created within a given date.
Remember each sample contains a patient. The actual SQL for this is simple,
I just need to perform a join, but where is the member function stored that
performs this SQL? How do i split the SQL to create Sample objects that
contain the correct patient objects?
3) The classes/objects will be viewed in a web form (i.e. i want to edit a
patient details, so I load the patient contents from the database into an
object which populates a web form) or in a pseudo data grid (i.e. searching
for a patient with the surname Smith and displaying all the results). I
didn't want to use a dataset as I would loose control over the appearance of
the search results/table displayed to the user. If I do use a dataset, there
is no need for an array of objects :S What am I to do?
These are the main issues im having developing the system. Coming from a
procedural PHP background, these issues seem very simple and easy to work
with, however being OO based makes them infinitely complex. The whole
running one query and the separate objects being created and nested
correctly it the real sticking point.
All advice and help appreciated. Please remember im a .net novice so if I
have missed a crucial facet of the technology, please do advice, i would
really appreciate it!
Thanks again, apologies for the long post.
Kind Regards
Taz
to both (apologies if it breaks some group rules).
I am making a web app in asp.net using c#. This is the first fully OO
application I will be making, also my first .NET application, so im looking
for any help and guidance.
Ok, my problems are todo with object and database abstraction, what should i
do.
I have defined certain objects my system will need, they are all linked.
Lets say these are
Patient --- Sample --- Sas
An Sas contains a Sample and a Sample contains a Patient. A patient can
exist on its own however a Sample needs a valid patient and an Sas needs a
valid sample.
At the database level i simply store 3 tables, one for each of the classes.
However, what is the procedure for loading my data back into objects before
I use them? I know I can make a static method within the class that loads
data, creates an object and returns it (although I was told this wasnt good)
or to use Data Access Objects (DAO)s as helper classes for my main classes
that do this work, again a good idea but i cant see it providing a solution
to one of my problems, see 2 below.
A few scenarios that are valid within the system:
1) I simply want to search the patients within the system. I could search by
patient parameters such as name and patientid. Will the patient class need
to contain code that performs this SQL query and returns an array of patient
objects, alternatively do I use a separate DAO (Database Access Object ) to
perform the patient queries? Now I need 2 classes to handle my patients (and
potentially 2 for Samples and 2 for Sas's etc etc).
2) I may want to search for all the samples created within a given date.
Remember each sample contains a patient. The actual SQL for this is simple,
I just need to perform a join, but where is the member function stored that
performs this SQL? How do i split the SQL to create Sample objects that
contain the correct patient objects?
3) The classes/objects will be viewed in a web form (i.e. i want to edit a
patient details, so I load the patient contents from the database into an
object which populates a web form) or in a pseudo data grid (i.e. searching
for a patient with the surname Smith and displaying all the results). I
didn't want to use a dataset as I would loose control over the appearance of
the search results/table displayed to the user. If I do use a dataset, there
is no need for an array of objects :S What am I to do?
These are the main issues im having developing the system. Coming from a
procedural PHP background, these issues seem very simple and easy to work
with, however being OO based makes them infinitely complex. The whole
running one query and the separate objects being created and nested
correctly it the real sticking point.
All advice and help appreciated. Please remember im a .net novice so if I
have missed a crucial facet of the technology, please do advice, i would
really appreciate it!
Thanks again, apologies for the long post.
Kind Regards
Taz