There are abuses of the class system, and then there are those beautiful, snowflake- like cases of abuse, those moments where you see the code, you understand the code, and you wish that, somehow, you could throttle the invisible person responsible for that code. Alex found this example:

public class Record_Base
{
	public DateTime RecordDateTime
	{
		get { return _recordDateTime; }
		set 
		{ 
			if (this.GetType().Name == "Record_PartRegister")
				_recordDateTime = value;
			else
				throw new Exception("Cannot call set on RecordDateTime for table " + this.GetType().Name);
		}
	}
}

This is special. You see, RecordDateTime is a member of the class Record_Base. Record_PartRegister is a child class. This means that the parent can’t set a property it implements itself. For bonus points, the original culprit didn’t bother to document this method as being profoundly broken. Alex only discovered this when trying to diagnose a mysterious, uninformative, and untyped exception.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!