4 ms·
> Yeah, that's a decent point. To answer your question, it's as if it's the string "secure string" for the purposes of other string methods. That’s a problem b
by pjerem 5y ago
> Yeah, that's a decent point. To answer your question, it's as if it's the string "secure string" for the purposes of other string methods.
That’s a problem because you are enforcing all your functions accepting normal strings to either have to check if it’s NOT a SecretString or to return some nonsense. For exemple a function that returns the 2 firsts characters without caring about secret string could be passed one as argument and return « *s ».
The Liskov Substitution Principle states that a function accepting an Animal (a String) should never care about wether it’s a Cat (a Secret) and don’t fear Animal (String) methods to return meaningful values.