Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
keathley
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
4 ms
·
1.
▲
by
keathley
5y ago
No, it literally returns you the first one. If you have a keyword list and use get your not going to be getting the benefit of duplicate keys.
2.
▲
by
keathley
5y ago
> These all feel like personal judgements about tradeoffs rather than actual hard rules. I'm glad it came across this way. These are all ideas that I believe have helped me build more maintainable systems. But that's just my ex
3.
▲
by
keathley
5y ago
I didn't make a very strong case for it. Overall, my experience has been that calling the side-effecting function in the case statement directly tends to be easier to maintain and easier to read. But, I think piping into case can work
4.
▲
by
keathley
5y ago
> General consensus is that there's a lot of things pointed out here that are good to think about and consider, but don't treat them all as gospel. Definitely not gospel. These are patterns that I tend to use and believe have h
5.
▲
by
keathley
5y ago
My general feeling is that if the errors matter, `with` probably isn't the right construct. In those situations I prefer to use case. That's been helpful in my experience.
6.
▲
by
keathley
5y ago
I agree on the performance characteristics. But if your using `get` then it doesn't matter that keyword lists have non-unique keys. You just get the first one.
7.
▲
by
keathley
5y ago
Sorry, "invent" had the wrong connotations there. I just meant that there are scenarios where crashing wouldn't be acceptable. And in that case, sure, you should prefer to handle the error directly. But, allowing the process
8.
▲
by
keathley
5y ago
Your talking about errors in the context of a web request or RPC. In those situations then sure, return an `{error, exception`} (that's the pattern I advocate for as well). But, I've found a lot of benefit from designing systems w
9.
▲
by
keathley
5y ago
Calling it "good and bad elixir" was probably overly charged. Its a little late to change it now, but something I'll consider in the future.
10.
▲
by
keathley
5y ago
You can certainly invent a scenario where using `Jason.decode!` wouldn't be appropriate. In that scenario, absolutely, handling the error and backing off is more appropriate. I'd also argue you shouldn't be doing side-effects
11.
▲
by
keathley
5y ago
Interestingly enough, my advice to not use `Map.get` is the most contentious point in the entire post. I didn't suspect that would be the case. I'm certainly not against using those functions and the additional checking can be of
12.
▲
by
keathley
5y ago
Thanks! I'm glad you enjoyed the article and it could provide some useful insights.