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'm in the process of learning how to use WCF (Windows Communication Foundation) to allow a client/server desktop application to communicate. The application's UI will be implemented using WPF, and we will probably use SQL Server for our database.

What I'm struggling with, is understanding how to structure such an application.

From what I've read, there are three components of a WCF application (which in the examples I've seen have existed as separate projects):

  • A WCF service
  • A WCF service host
  • A WCF service client

My question then, is - should these projects solely implement the functionality of sending/receiving data from the client/server? Would it make better sense this way?

Would it make sense to create a separate WPF (Windows Presentation Foundation) project to implement the UI for the application?

And so, when I need to send/receive data from the client/server, I could simply invoke the operations provided in the WCF projects that I have created?

For anyone who has built similar applications previously, perhaps you could explain what worked best for you in terms of structuring your application?

For example, if I create a user registration page. When the user clicks the 'Register' button, the client application will need to send the data to the server. In this case, could I just invoke the methods provided in the WCF projects to send the data?

Also, what data structures worked best for you when sending/receiving data? My initial thought is sending/receiving XML containing the data. Is this an option that is easy to implement?

I realise that answers to this question may well be a matter of opinion - unless there are specific best practices that I'm not aware of.

Thank you

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

Your server solution should contain:

  • The database layer.
  • The WCF server.

Your client solution should contain:

  • The WPF UI.
  • The WCF client.
  • Anything else it needs.

Each of these would be a separate project within the single solution. The WPF UI would be the main application with all the other projects defining assemblies. The WPF would then call the WCF client to request data from the server and send data back to the server. It might also listen to events raised from the WCF client.

However, this is just a theoretical structure. You might find that you have to tweak things when you come to implement it.

share|improve this answer
add comment

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.