Frage

Example instead of creating a class library and referencing it in your main program, you expose the method as a web service.

This way you do not need to recompile when you want to change the method, you can change anything you need to change however, it comes with network overhead :(

Thinking about doing it but not sure. (not liking the network overhead it seems unnecessary???).

War es hilfreich?

Lösung

There are a lot of reason why decoupling layers is a good idea, SOA is one of the most radical solution to achieve that but avoiding compilation of the consuming component is probably not a good criteria to decide if you want decoupling or not.

Andere Tipps

This way you do not need to recompile when you want to change the method...

This is not true. If you need to change a method, you need to recompile the web service host.

Using a SOA is only a good idea when you have a distributed network application, that most likely also needs to be cross-platform. In case of a local app using services to perform a routine tasks of the application is wrong.

You can implement an SOA style without using web services. This will mimic the separation that you are trying to achieve. As long as the public methods are not changing - then you do not have to recompile the consumer. The only time this is not true is if you are using versioned files and you change the version.

public class MyFakeService
{
   public static int DoSomethingHere(int value1, int value2)
   {
       // Do stuff here

   }
}

Now in your consumer....

public void MyMethod()
{

int value1 = 3;
int value2 = 4;

int newvalue = MyFakeService.DoSomethingHere(value1, value2);
Console.WriteLine(newvalue);

}

Regardless of how you change MyFakeService - as long as the public and class signatures remain the same - you are fine.

Idea of web services is not to stop re compiling. You should use web services if you don't know the client and need to make a common communication path between client and server. For an example when you deploy a web service even a .Net client can generate code by looking at the wsdl and invoke the service.

However if only your main program access this method there use it as a library is the better way.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top