Forget the comment, the design is already awful from just three lines of code.
I’d love to know why you say that. I’m learning the language and could use some insights
We are missing a lot of context but strong type systems give you the superpower to make unwanted state unrepresentable:
Here we can see the class member
invalidbeing used as a flag to express that this method didn’t work out as expected. It is very easy for someone else down the line to ignore/forget (/never even knew about it) to check thatinvalidflag and just use the result regardless, which will likely lead to more failures later on.Instead the author should directly return something that indicates invalidness. This could be as simple as returning a boolean or especially if this is a constructor it would be better to throw an error.
That way the invalid class never even gets instantiated and is therefore impossible to misuse. All validated by the type system.
People have IDEs policing their language now?
If they choose to. I have the natural language suggestions enabled since it often helps me make my comments flow better. For this suggestion I’d add it to the ignore list, which you can always do.
Of course you are not getting a post for the vast majority of actually useful suggestions it gives, like fixing accidental commas or typos (that result in a valid word, but one that doesn’t make grammatical sense where it is).



