Original Post
Hi there,
I asking myself for a while how to design correctly.
Let me get an example: (C#)
[source lang="csharp"]class SimpleClass
{
private int a = 0;
private int b = 0;
private int c = 0;
public SimpleClass(int a, int b)
{
this.a = a;
this.b = b;
CalcC(); // CALL DESIGN A
this.c = CalcC(this.a, this.b); // CALL DESIGN B
}
//METHOD DESIGN A
private void CalcC()
{
c = a + b;
}
//METHOD DESIGN B
private int CalcC(int first, int second)
{
return first + second;
}
}[/source]
I always used variant A when working with private methods. But then I realised that I can't put my methods in unit tests, because they are working with the class properties and don't return any values.
I working like variant A since years, and it would be nice if somebody can tell me something about this and the dos and don'ts of this.
Thanks.
I asking myself for a while how to design correctly.
Let me get an example: (C#)
[source lang="csharp"]class SimpleClass
{
private int a = 0;
private int b = 0;
private int c = 0;
public SimpleClass(int a, int b)
{
this.a = a;
this.b = b;
CalcC(); // CALL DESIGN A
this.c = CalcC(this.a, this.b); // CALL DESIGN B
}
//METHOD DESIGN A
private void CalcC()
{
c = a + b;
}
//METHOD DESIGN B
private int CalcC(int first, int second)
{
return first + second;
}
}[/source]
I always used variant A when working with private methods. But then I realised that I can't put my methods in unit tests, because they are working with the class properties and don't return any values.
I working like variant A since years, and it would be nice if somebody can tell me something about this and the dos and don'ts of this.
Thanks.