?
Solved

.Net n-Tier Data Access Layer

Posted on 2012-09-11
5
Medium Priority
?
910 Views
Last Modified: 2012-09-12
Hello all

I manage a system which has several different winform front ends used at multiple locations.

Admittedly when I first created the system I didn't understand much about OOP or n-tier design so it's all a bit of a mess.

I did plan on creating a web service which would act as the DAL/BL but upon further reading I hear this isn't the best idea, performance being an issue for one thing.

So what's the best way of going about this? I don't want to move to a web based version of the front ends as it doesn't give me the flexibility that I require as I often need to access different types of hardware directly. But I'm uncomfortable having all of the data access code in the program and for it to be accessing the database directly. It also creates more work having to update all of the programs individually.

Should I just take the limitations of and performance issue of using a web service to do this as unavoidable?

Many thanks
0
Comment
Question by:badpilot
  • 2
  • 2
5 Comments
 
LVL 18

Accepted Solution

by:
DarrenD earned 2000 total points
ID: 38390032
Hi,

Firstly you can create WinForms apps using web services with absolutely no issues. I actually prefer WinForms apps over WebApps but thats just a personal preference.

I did plan on creating a web service which would act as the DAL/BL but upon further reading I hear this isn't the best idea, performance being an issue for one thing.

One of the reasons that you would use a distributed architecture is that it allows scalability. This means that you can add more servers into the mix if you found that you needed better performance. All of the hard work is done on there server which means that your PC's do not have to do the donkey work. This is handled on the server where you've probably spent alot of cash on with multiple processors etc...

I would also suggest that the performance hit with todays PC/Server speeds is a non issue unless you are doing something very computationally intensive, which, again should be done on there server.

Using WCF you can connect to your service using HTTP or TCP depending on what you want to do. You can also connect using various other protocols so it doesn't havce to use a web server (although you would have to create your own server for other protocols)

Another reason is maintenance which you pointed out. You currently have to update the code base across multiple exe's. Keeping all business logic in one place is a good idea.

Accessing hardware connected to a PC is different and would probably require some of the code base to stay within the exe.

There are many more reasons for using a distributed architecture The simple fact remains if you need a distributed architecture then create one otherwise don't. This is one of those
It Depends
areas.

Let me know if you require more info.

Hope this helps,

Darren
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38390059
WCF is would be better option than web services. You can also just separate the DAL/BL into separate DLL(s) and it will save you from having to make changes to all programs for changes in DAL/BL.
0
 

Author Comment

by:badpilot
ID: 38391236
Thanks, I think I was just looking for re-assurance that this was the correct path to take. The system (as is usually the case in these situations) has grown organically which is why I've gotten to this point.

One more question if you will - I understand that performance wise, error checking/validation should be placed in the UI layer as to reduce the number of calls to the service - this seems counter-intuitive though as it would require an understanding of how the service operates.

Should I just get this idea of performance out of my head and place all of this on the server? Computing power isn't an issue but the connections used for these applications in some of the remote locations are ropey at best. I suppose I'm concerned about time outs/duplication of data/support calls.

Thanks again.
0
 
LVL 18

Expert Comment

by:DarrenD
ID: 38391294
Hi badpilot,

I normally perform all of the validation on the server.

I have a single method that checks all of the data sent up the wire and validats it. If there are errors then the error fields are sent back in a message. So if there were two incorrect pieces of data set back one error message with both of the validation messages in it.


You can check some of the data on the client if you want like numeric only fields to stop incorrect input but that's about all I do.

If some of the connections are ropey then you may have to look at other options... I've used WCF where our offices have simple broadband connections and it all seems ok, however, if you are talking dialup or something like that then maybe you will have to keep a local copy of the database and sync this up when the connection is idle e.g. at night....

Again, these are the "it depends" questions as we only have so much of your knowledge to go on...

Cheers,

Darren
Darren
0
 

Author Closing Comment

by:badpilot
ID: 38391376
Thanks very much for your help, greatly appreciated.
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question