The new framework is just pushing the assumptions that were implicit in things like Left, Right, etc out in a way someone, not you, could plausibly read your code in the future & not have to consult the LR on every method call to the framework to see what it may or may not do and how it might silently fail to do what you expected (like return < 3 characters when you ask for 3)
When I started here it took me forever to get up to speed because assumptions were hidden in code and in calls to the framework and the use of Variants (evil evil evil) and the magic they’d do. It made tracking down bugs VERY time consuming.
Anyone hate that VCP files would flip flop values from string to integer etc ? VARIANTS !
I’ve been hunting those causes for nearly 7 years.
So, and this IS only my personal opinion, things like the old LEFT, or Kems new replacement, that can silently fail to return what I asked for should be loud & obnoxious when they do. This way my code can, in code, put the assumptions I’m making about how to deal with such a situation right there where it matters and where I need to worry about it.
Now IF YOU ALREADY test for getting less than what you asked for then you’re already doing exactly what I wrote should be done just using if then or select case instead of an exception.
You wrote your code in a way that the assumptions ARE present right where the data is being munged about.
ie/ IF you’ve already done this
dim t as text = s.Left(3)
if t.Length() <> 3 then
// some error handling code
end if
its not fundamentally different than
try
dim t as text = s.Left(3)
catch
// some error handling code
end try
you have error handling either way (and in the case of the exception you don’t always evaluate the IF thereby gaining tiny speed ups all over the place)
In the case you DONT care the new framework simply makes you make it VERY explicit you dont care by writing
try
dim t as text = s.Left(3)
end try
But at least IF you do write this when you have a bug and come back to it later instead of wondering if
dim t as text = s.Left(3)
is just a dumb mistake on your part and you forgot to handle the exception or a real but
If you see that you wrote
try
dim t as text = s.Left(3)
end try
you can see that NO you DID in fact realize that there could be cases where you got less than you asked for and that you thought about it at the time (albeit maybe incorrectly)
I like being able to write more correct code initially & being forced to state my assumptions right there.
In order to do that today I end up often writing at least the same amount of code as with the new framework.
YMMV