Ran across the C# code below (piece 1) - reduced for clarity, it also had instance methods, many more members, etc. Am I missing some very smart programming pattern here or it can be reduced to piece 2 without hassle? The Address() type is very simple, more a data transfer object really.
Piece 1:
public class MyStuff
{
private IAddress _address;
public MyStuff()
{
SetAddress(_address = new Address());
}
private void SetAddress(IAddress addr)
{
_address = addr;
}
}
Piece 2:
public class MyStuff
{
private IAddress _address = new Address();
public MyStuff()
{
//The constructor is probably redundant too
}
}