3

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?

1
  • Is this for a web site or a desktop application? Or mobile? Have you looked at implementing a custom Membership Provider Commented Mar 21, 2013 at 19:16

1 Answer 1

3

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.

5
  • 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. Commented Mar 21, 2013 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
    Commented Mar 22, 2013 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. Commented Mar 22, 2013 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
    Commented Mar 22, 2013 at 17:33
  • +1 for (paraphrasing) design to your needs and (afterwards) adapt. And I emphasize the implication of separation of responsibilities.
    – radarbob
    Commented Mar 28, 2013 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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