Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've seen projects that use N-tier with WCF. When creating a WCF project in the solution it is often named with the word "service?"

The main questions:
Why and what benefit do you have when using WCF in relation to N-tier?

Which situation should be used with WCF and N-tier?

share|improve this question
2  
What problem are you having with WCF? –  ChrisF Aug 9 '11 at 14:37
2  
Do you know what WCF is and what benefits it provides? –  Bernard Aug 9 '11 at 14:58

2 Answers 2

up vote 6 down vote accepted

WCF can be used as one of the tiers.

I suppose the whole point is that, if you create your service tier using WCF, you can re-use it with other tiers. For example, you can have a web page and a WPF application that both display data from the same WCF service.

share|improve this answer

Are you sure you're not confusing WCF (Windows Communication Foundation) with WPF (Windows Presentation Foundation)?

WCF is a communication service (mini-framework?) that's designed to allow for rapid development of web services. Check out the whitepaper.

Because it's not a programming architecture in the same way as N-Tier or MVC is, it can be integrated into an existing system. I've used this in an N-Tier, Winforms project and it works just fine. It may be easier to integrate into a WPF or MVC project than an N-Tier or Win/webforms project (because the newer generations of .Net are built with MVC style design patterns and WFC in mind, while the older based stuff are generally backported until they get rewritten), but the functionality (and thanks to the CLR, the performance) is still largely the same.

WPF is a system designed to replace the classic Winforms/Webforms/N-Tier architectures, allowing application developers to use similar languages and techniques to build both desktop/thick-client and web/thin-client applications. By default, it uses a design pattern known as M-V-VM (Model-View-ViewModel), which is similar to MVC. Check out its info.

With WPF, trying to use it in an N-Tier manner isn't a good idea and probably wouldn't work anyway. It's not designed to be N-Tier, so you'd be shoe-horning it into an architecture/design pattern that it wasn't meant to fit into.

So, to directly answer your questions as worded - you'd use WCF in N-Tier when you want the benefit of rapid development of communication services (to add, say, an API), but already have a N-Tier based system developed. It saves you having to re-write your system in a new architecture just to add communication features. When done right, N-Tier can be as modular as MVC, and so adding in a WCF tier (or making it part of a communication tier) shouldn't be difficult, nor should it be that much different from using a WCF service in an MVC-style project.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.