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.

We are building a web interface to a tiered membership system, which will interface with a third-party CRM web service for the creation and management of accounts. The web service, unfortunately, is not yet built; however, we need to begin work.

I have created an interface, IMembershipService, in which I am beginning to define "best-guess" prototypes, so we can begin building our User Controls. Most of these methods will return some data bundled in a Model object, e.g.:

ContactModel GetContact (string userId);

When the web service methods become available, I will create a concrete implementation of IMembershipService that will wire up the controls to the web service.

The problem I have is that I don't yet know whether the web service will consist of:

  • calls returning complex objects; e.g. a User object with a nested Membership object, which, in turn, has a nested PaymentMethod object
  • simple calls for specific pieces of information; e.g. String GetUserMembershipType (string userId);

This is causing me to have trouble specifying the structure of the models and interface, which is causing problems for the developers beginning work on the User Controls:

  • If the service returns complex objects, I don't want my IMembershipService methods to be too simple, forcing me to use multiple web service calls where it is not necessary.
  • If the service consists of simple calls, I don't want to have a load of complex models defined that I then can't implement, thereby having to do a load of refactoring.

In theory, creating IMembershipService should allow me to abstract away from the actual nature of the web service, but the fact that each call to a method in IMembershipService will, ultimately, result in a web service call, thereby adding overhead, is making this difficult to spec.

How can I design my models and IMembershipService in order to minimize the amount of refactoring I have to do when the nature of the web service becomes less elusive?

share|improve this question
    
Is this for a web site or a desktop application? Or mobile? Have you looked at implementing a custom Membership Provider –  Mike Brown Mar 21 '13 at 19:16
add comment

1 Answer

Decide on the most convenient interface for your application, and define an interface according to that. What information will you need, and in what discrete units? Define models according to those units.

After all is said and done, that's the information you need. Let the implementation later be an adapter to the webservice. It won't matter if it needs to do multiple callstothe webservice or not - that's just an implementation detail.

share|improve this answer
    
I agree wholeheartedly with the first paragraph. But, depending on network layout, making multiple remote calls can be much more than a minor implementation detail -- it could make or break the application. –  Wyatt Barnett Mar 21 '13 at 23:44
    
@WyattBarnett How do you figure? I agree it's not a minor implementation detail - with many remote calls it will take longer time to return a result, but there is no way to escape that anyway. If you need the calling method to return immediately, it is possible to opt for an asynchronous interface instead, is that what you are referring to? What I am getting at is that if the remote call layout makes or breaks the application, I'm not sure what the interface on the client side could do to fix that? –  Max Mar 22 '13 at 7:38
    
Remote calls are the most expensive thing one can do in a program from a performance standpoint. They should not be treated like local method calls no matter what WCF wants to make you think. I've seen cases where devs build a pure SOA entity like they are making local calls and it even works great when they are developing on their own machines. But when you make that call over a remote connection performance and perception of value go through the floor. –  Wyatt Barnett Mar 22 '13 at 15:29
    
@WyattBarnett I agree completely. But that is a concern when writing the service - the client is pretty much forced to use their methods, right? My answer is strictly from the perspective of the client... Should I make that clearer in the answer? –  Max Mar 22 '13 at 17:33
    
+1 for (paraphrasing) design to your needs and (afterwards) adapt. And I emphasize the implication of separation of responsibilities. –  radarbob Mar 28 '13 at 16:36
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.