We've all seen folks reinvent the wheel. Some folks reinvent booleans. Others don't know when to stop. Some treat time as though it were malleable. Still others have all sorts of trouble finding dates.
However, Nathan encountered some code where folks seemed even more determined than usual not to use the built-in features of the language.
He was poking around an API that his team was forced to use and was looking into the source code for what appeared to be an enumeration:
public class SubscriptionStatus : Enumeration { public static readonly SubscriptionStatus ACTIVE; public static readonly SubscriptionStatus CANCELED; public static readonly SubscriptionStatus EXPIRED; public static readonly SubscriptionStatus PAST_DUE; public static readonly SubscriptionStatus PENDING; public static readonly SubscriptionStatus[] STATUSES; public static readonly SubscriptionStatus UNRECOGNIZED; protected SubscriptionStatus(string name); }
Foolishly, he wondered what Enumeration was, hesitantly said to himself "We need to go deeper", and then he dove, face first, down the rabbit hole...
public abstract class Enumeration { protected string Name; protected Enumeration(string name); public override string ToString(); }
They had rolled their own enum. Try as he might, Nathan could not even begin to point out the number of things wrong with this.