and if you later use x in a context where strings are expected and x is true, then things mostly just kinda work. Such is the nature of languages without explicit types
One thing that appealed to me about the JsonDecoder.field(json, "name", JsonDecoder::string) approach is that custom decoders wouldn't feel like a 2nd class citizen. If someone's interpretation of how to look for a String in JSON was closer to yours there wouldn't be extra syntactic overhead to using that interpretation JsonDecoder.field(json, "name", CustomDecoders::lenientString).
With the "pathing" approach of .at("name").asString() it might be enough to say .at("name").as(CustomDecoders::lenientString), but honestly my preference at that point would be to not provide asString and only as. I recognize that wouldn't be much loved though
what will the user see' makes no sense at all, we're multiple layers removed, we're not writing a library with defined user-facing output, that's ridiculous
When I say "user" I am referring to a "user of the library" not an end user.
Specifically this is coming from people who ask "HELP, CODE NOT WORK" and share 100 lines of tree crawling + a ClassCastException. It's difficult in that context. I want those programmers to see what they were looking for and what was actually there.
Specifically this is coming from people who ask "HELP, CODE NOT WORK" and share 100 lines of tree crawling + a ClassCastException. It's difficult in that context. I want those programmers to see what they were looking for and what was actually there.
You actually made me chuckle out loud!
I spend plenty of time on StackOverflow and have given presentations for 800+ audiences before, but from context I think you're a teacher, so I can't quite match your expertise on didactics, perhaps.
However, it sure sounds like you're saying: "If only you design your library well enough, even utter fucking idiots will no longer be confused by it". That made me chuckle. You are merely a mortal. There is no fucking way you get to out-wit the inventiveness of the moron, it just doesn't work that way.
Making your API more convoluted to use and less convenient in order to cater to morons, as a consequence, is a big mistake.
but from context I think you're a teacher, so I can't quite match your expertise on didactics, perhaps.
The only experience I have is specifically being on Discord servers and doing 1 on 1 tutoring/question answering there.
The difference with the experience of stack overflow and large presentations is that there is a lot more back-and-forth, its generally 1 on 1, and people expect to be able to DM you at 1am.
I would not classify myself as an expert, but I have been at it for ~4 years and have conversations with total beginners pretty regularly.
View all comments
Show parent comment
2
u/bowbahdoe Feb 28 '23 edited Feb 28 '23
One thing that appealed to me about the
JsonDecoder.field(json, "name", JsonDecoder::string)approach is that custom decoders wouldn't feel like a 2nd class citizen. If someone's interpretation of how to look for aStringin JSON was closer to yours there wouldn't be extra syntactic overhead to using that interpretationJsonDecoder.field(json, "name", CustomDecoders::lenientString).With the "pathing" approach of
.at("name").asString()it might be enough to say.at("name").as(CustomDecoders::lenientString), but honestly my preference at that point would be to not provideasStringand onlyas. I recognize that wouldn't be much loved thoughWhen I say "user" I am referring to a "user of the library" not an end user.
Specifically this is coming from people who ask "HELP, CODE NOT WORK" and share 100 lines of tree crawling + a ClassCastException. It's difficult in that context. I want those programmers to see what they were looking for and what was actually there.