2 ms·
This is the problem with blog articles showing minimum code examples. Minimum code examples are important because the more code you show the more your audience
by ItsMonkk 5y ago
This is the problem with blog articles showing minimum code examples. Minimum code examples are important because the more code you show the more your audience spaces out and moves on. The comments here are saying "but you just moved it to somewhere you didn't show", but it's the nuance in this comment that really gets to why this can be valuable.
> We likely don't care about all 8 states - rather 4 or 5, but complexity increases.
When you have only 2 valid use-cases, you need the code for both. It has to exist. When you have 5 valid use-cases and 3 invalid use-cases, making those 3 invalid use-cases impossible leads to better maintainability. So the minimum code example isn't actually the minimum code example to show why it is effective.
And yeah, product types and the ability to ensure that if you don't handle a case that is possible you get a compiler error is clearly the ultimate result the blog author is searching for.