Wednesday, January 20, 2010

Wow this one takes the cake.

So of late I have been working on a older system created in .NET by a delphi programmer. It has some very interesting behaviors.

private string Xml { set { this.Address = value; } }

public FooClass(PaymentInfo info)
: base(info)
{
this.Xml = string.Format("Some random string goes here" . .

The problems with this are many. The least of which would be the fact they created a property Xml that just sets another property Address. Why would you do this. You can just call Address.

4 comments:

Ishpeck said...

Maybe it's some kind of legacy mutation. Or maybe he was given a deadline similar to the one CFx gave you along with a similar existing code base.

Erin said...

Written from scratch in c# and he might have had a deadline but it would have been easier to just say this.Address and not build yet another property in the code base that can only be set and never accessed.

Mel said...

Maybe he had to modify the class to fulfill some pre-existing role that called for a property called XML. And rather than re-write all that existing code he just slapped it in there and had it direct to the actual property that mattered.

Or maybe he was just an idiot.

Erin said...

Look closely Mel where is the get part of the property. It is a write only prop and there is no requirement for the Xml it is only used in that one place.