Question 3 tier design question

carl6885

New member
Joined
Apr 1, 2012
Messages
2
Programming Experience
Beginner
Hi

I am new to this forum so thank you in advance to any assistance given.

I have a question in regards to 3 tier design and where a function should sit (best practice wise as I know I can put it anywhere)...

My set up is....

Database Layer ---- For example clsTeachingLocationsDB.vb
Business Layer ----- Validators etc etc
Presentation Layer----- For example frmCandidate.vb

In my database layer I have for example a function getting a list of TeachingLocations from the database then in the presentation layer there is a function that loads the data into a combo box etc.

Now I need to retrieve TeachingLocations specific to the Candidate selected...

Now would the database work sit in clsTeachingLocationsDB.vb or clsCandidateDB.vb?

I guess another question would be for the the Candidate class how would I bring in the teaching locations and store them.....

Thanks in advance
 
You would have a data access class for each entity and whatever entity you are retrieving determines the data access class the code goes in. If you have a Parent entity and a Child entity then you have a ParentRepository and a ChildRepository. If you are getting Child objects then you use the ChildRepository, even if you're filtering by ParentID.

How you retrieve related entities depends on various factors. If you use something like Entity Framework then it's pretty much built in. Otherwise, if you have a ParentService and a ChildService then the ParentService would get Parent objects and it would then use a ChildService to get the Child entities for each Parent.

Note that a repository is a data access class and a service a business logic class.
 
You would have a data access class for each entity and whatever entity you are retrieving determines the data access class the code goes in. If you have a Parent entity and a Child entity then you have a ParentRepository and a ChildRepository. If you are getting Child objects then you use the ChildRepository, even if you're filtering by ParentID.

How you retrieve related entities depends on various factors. If you use something like Entity Framework then it's pretty much built in. Otherwise, if you have a ParentService and a ChildService then the ParentService would get Parent objects and it would then use a ChildService to get the Child entities for each Parent.

Note that a repository is a data access class and a service a business logic class.

Hi, thanks for replying so quickly, I was trying to work it through coding it and what you have written is pretty much where I was getting so it now makes perfect sense.

Thanks for taking the time to reply.

Carl.
 
Back
Top