4 ms·
Personally, I would call it a smell to have classes that only extend minor state, especially when this forces immutability into paradigms that do not have immut
by achr2 11y ago
Personally, I would call it a smell to have classes that only extend minor state, especially when this forces immutability into paradigms that do not have immutability as a prime component (.net UI frameworks for example). To me IsActive/Deleted is a property of a User, not a type of user.
- alkonaut 11y agoIn this contrived example, the deletedDate alone is enough to create the required states (Deleted being when there is a deletedDate) without creating any invalid date (Deleted without deleted date or vice versa). In general though, if there were 3 states (active, suspended, deleted) where some states required more data than others, I'd probably make a struct+enum to create the equivalent of the F# type. The user can expose the state while hiding the fact that it has a more complex internal field.