Is it correct to control how the service works from the caller of this service? I had such a problem today, and don't know if my solution is good or not. Hope someone more advanced can give me a feedback. Here is my problem:
I have got a service with method Foo:
public class Service
{
public int? Foo(int? number, bool throwException)
{
int? result = number;
if (result == null)
{
var result = ...
if (result == null && throwException)
{
throw new Exception("ZZZZ");
}
}
return result
}
}
Now in Caller class I got 2 methods where I invoke this Service:
public class Caller
{
public void Test1()
{
...
Service.Foo(number, TRUE);
...
}
public void Test2()
{
...
Service.Foo(number, FALSE);
...
}
As you can see for Test1 im sending flag throwException TRUE, and for Test2 FALSE, is it good practice to control how the Service's flow go from the Caller's methods?
Aucun commentaire:
Enregistrer un commentaire