|
|
|
|
|
by lixquid
826 days ago
|
|
Program logic fundamentally has to contend with different conditions.
Sometimes the user will be logged in and have friends, sometimes they won't. The "maybe" style has the inconsistency embedded in the type system; it's
impossible to have an invocation to getFriends and then not handle the
resulting possibility of not being logged in. Shifting it up to the caller just means that you're going to have to remember
to ensure the user is logged in before calling getFriends otherwise you'll get
some kind of error, which might give you more control, but now there's no
guarantee in the type system that you've handled the case where the user isn't
logged in. Writing ifs everywhere to handle failure conditions might be a bit of a pain,
but that's more of a failing of the language than the style. |
|