339
What are your programming hot takes?
(lemmy.ml)
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev
My point is, you won't ever try. You'd only use "weak" variables inside the function you're working on.
It's explicit when you absolutely need it to be, when the function is being called and you need to know what arguments to pass and what it'll return
A string being parsed as a date-time is presumably user input, which is potentially invalid.
When you say user, you mean a user of a function? In that case PHP would throw a TypeError, and presumably only happens when developing/testing.
If you mean in production, like when submitting a form, an Exception may be thrown. In which case you catch it and return some error message to the user saying the date string is invalid.
By “user” I mean the person who is using the application.
Using exceptions for handling unexceptional errors (like invalid user input) is a footgun. You don't know when one might be raised, nor what type it will have, so you can easily forget to catch it and handle it properly, and then your app crashes.
Even if I coded the form by hand and that happened, it's on me, not on the programming language.
But I don't, I use a framework which handles all that boilerplate validation for me.