Let's say I have defined the following class:
public abstract class Event {
public DateTime Time { get; protected set; }
protected Event(DateTime time) {
Time = time;
}
}
What would you prefer between this:
public class AsleepEvent : Event {
public AsleepEvent(DateTime time) : base(time) { }
}
public class AwakeEvent : Event {
public AwakeEvent(DateTime time) : base(time) { }
}
and this:
public enum StateEventType {
NowAwake,
NowAsleep
}
public class StateEvent : Event {
protected StateEventType stateType;
public StateEvent(DateTime time, StateEventType stateType) : base(time) {
stateType = stateType;
}
}
and why? I am generally more inclined to the first option, but I can't explain why. Is it totally the same or are any advantages in using one instead of the other? Maybe with the first method its easier to add more "states", altough in this case I am 100% sure I will only want two states: now awake, and now asleep (they signal the moments when one awakes and one falls asleep).