I have a bunch of classes that have a set of dependencies. Dependency Injection for this project will be overkill, so currently we have the following pattern in a number of cases:
public MyClass() : this(null, null) {}
public MyClass(Dependancy x, Dependancy y)
{
this.x = x ?? new Dependancy();
this.y = y ?? new Dependancy();
}
I don't like this code, but I'm not totally sure why. One reason would be the fact that it fiddles with parameters that are passed in, the other is that I might want the parameter to be null, and stay null.
Are there any strong reasons to avoid/use this pattern or any other, or is it basically just personal preference?