I need to design a service that preforms calculations, the calculations are of the form of invoicing a method and returning a value in some manner.

One of the requirements is that when a new calculation is made available I won't need to take down the entire system.

I thought of one of the method for achieving this, but I am not satisfied with my design which basically is not type-safe and error prone (and in this way achieves its dynamic abilities), I would like to show you what I had in mind and hope that the answers would help me make implements to achieve goals such as type safety. I am writing in C#, but this shouldn't matter too much.

My way: I thought about doing this is by having a server that receives XML's (basically a string) that includes the name of the calculation followed by the input parameters (different calculations can receives different amount of input arguments). The server would then use the name of the calculation requested to write the request to another server which preforms the specific calculation requested and writes the resulting output as XML to a dedicated area where the requester can read it. I intended to use an MQ for implementing sending and routing messages, but this is more of an implementation detail.

The advantages in my way is that the requester can send an XML requesting a new service and my server would know how to handle the request (just route it to some queue so that a new program doing the new calculation would be made) - this is without having to update Dll's on the client side and more importantly is that all existing calculations offered by the service are available (e.g the sever doesn't know which calculations actually exists thus no need to take it down).

The disadvantages are that the XML is a basically a string with all related disadvantages about type safety (moreover - someone can get the number of parameters wrong!).

One way to mitigate this is giving the client a new dll for each service with an interface with a method and an implementation that serializes the data correctly and sends it to the server - but this isn't ideal mainly because I don't want my code to sit at the client (say I have bugs or upgrade my IO component, now I have to notify and update code for my users).

What do you think about my solution ? I would appreciate any improvements, especially ones that can make the design more robust and less error prone.

  • How would you achieve this if there was no requirement to be always-on? Would there be any way to achieve type-safety then? – JDT Jul 31 '16 at 12:46
  • @JDT - I could update an interface on both client and server and invoke a method on the server, using WCF for example – Belgi Jul 31 '16 at 12:47
  • In that case, your 'strong typing' is merely a convenience provided by WCF. If you send XML and provide your own parsing and checking (which is what WCF does for you) you can achieve the same thing. – JDT Aug 2 '16 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.