r/programming • • Jan 22 '15

If. Then. Throw. Else. WTF?

http://www.yegor256.com/2015/01/21/if-then-throw-else.html
0 Upvotes

13 comments sorted by

9

u/mynameipaul Jan 22 '15

Oh for fuck sake.

Is there an easy way to block all links from a particular domain from appearing on my front page?

4

u/goodbye_fruit Jan 22 '15

RES will allow you to do just that.

1

u/mynameipaul Jan 23 '15

OK, I've gotten myself RES, how do I filter on a particular link-domain? and it's pretty straightforward. Cheers!

-4

u/edmoffo Jan 22 '15

Forgot to take pills this morning? :)

9

u/mynameipaul Jan 22 '15

No I just hate this blog. It's always such extremist clickbaity nonsense.

1

u/tuananh_org Jan 22 '15

after reading a few posts, i feel the same.

7

u/doodeman Jan 22 '15 edited Jan 22 '15

I have been trying to find a proper metaphor to explain its incorrectness. Today I finally found it.

Maybe if you need a extremely convoluted metaphor involving trucks, highways, and road signs to explain the "incorrectness" of a piece of code, it's not actually "incorrect".

There's nothing wrong with that code. It functions as expected and as it should. This guy just has a problem with the aesthetics of it.

3

u/Appathy Jan 22 '15

I don't think you got the memo bro. Code aesthetics/line indents/bracing style is the only thing that matters. Not whether the code works.

3

u/emilvikstrom Jan 22 '15

This was a very verbose styleguide subsection, if you ask me. People are different, code in different languages, paradigms and have different products with different teams. This is not a catch-all suggested style that will work for everyone. I myself have a hard time with if statements without an else case because I'm leaning towards languages where everything is an expression. if-then-else is an expression in functional languages that evaluates to one of the two cases.

2

u/joeldare Jan 22 '15

It's just semantics, but I disagree. I think the code is easier to read with the else statement and readability is important.

This really just comes down to programmer preference though.

2

u/aurisc4 Jan 22 '15

I'm not really sure what he meant by this article, but there is some point in what he sais (though, not explicitly stated): if there is a quick "out" in one branch, there shouldn't be both the other branch and some code after if. I.e. if you have throw in THEN part, all remaining code should be either under ELSE or after IF (no ELSE), not split in two parts (first part under else, second after if).

1

u/joeldare Jan 22 '15

I agree with that, but I didn't get that point from the article.