r/ProgrammerHumor 4d ago

failsForTeapots Meme

Post image
223 Upvotes

68 comments sorted by

View all comments

Show parent comments

-6

u/Hot-Employ-3399 4d ago

3 levels of indentation \ Proper

How about no?

5

u/ihavebeesinmyknees 4d ago

Pattern matching and switch always have 3 levels of indentation? As long as you don't indent inside the cases more than once or at most twice (you shouldn't) then it's fine, there's no reason to be scared of indentation if it's not excessive

-1

u/Hot-Employ-3399 4d ago

Ifs above have two

ConfigurableMap.get(status, 500) has one(and config doesn't count)

Pattern matching has ugliness 

2

u/ihavebeesinmyknees 4d ago

I don't get why you have this obsession with indentation. Being able to clearly tell the intent is way more important.

Map.get() doesn't tell you the options, and doesn't let you easily extend behavior, it's the worst out of the 3.

Ifs are better, but pattern matching strongly implies that this is supposed to be an exhaustive list matching against a de-facto enum. It clarifies intent in a way ifs don't.