A
Andrew Robinson
I have never done this or seen this but thought it might be useful. What do
you think of it? This is a very simplified example but frequenly when
reusing an object, I find myself spending a lot of time insuring that I
don't carry values over from the previous use. This insures that each of
these objects are in their own scope. (I am not looking for a 'using'
statement here since my object doesn't implement IDispose.) I guess a good
alternative would be be to wrap each of these entities in a different sub
method.
public void SavePhone() {
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "123";
phone.Save();
}
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "234";
phone.Save();
}
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "345";
phone.Save();
}
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "456";
phone.Save();
}
}
let the opinions fly!
you think of it? This is a very simplified example but frequenly when
reusing an object, I find myself spending a lot of time insuring that I
don't carry values over from the previous use. This insures that each of
these objects are in their own scope. (I am not looking for a 'using'
statement here since my object doesn't implement IDispose.) I guess a good
alternative would be be to wrap each of these entities in a different sub
method.
public void SavePhone() {
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "123";
phone.Save();
}
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "234";
phone.Save();
}
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "345";
phone.Save();
}
{
PhoneEntity phone = new PhoneEntity();
phone.Number = "456";
phone.Save();
}
}
let the opinions fly!