

Wait, What? - wallflower
https://github.com/mongodb/mongo-java-driver/blob/master/src/main/com/mongodb/ConnectionStatus.java#L213

======
jackcviers3
This reads like they were in a hurry. How many of us have written crazy
debugging lines? There seems to be a morbid desire to crawl gh source code for
obscure wtfs and expose the coder as a Bad Programmer. This line is in an oss
project, enter an issue, fork it, and submit a pull-request. Way more
productive way of wtf mining than submitting ssomething to community ridicule.

------
mbenjaminsmith
Looks like it's preventing most exceptions of that type from being logged.
That would make sense if it's the type of exception likely to repeat itself
constantly (until addressed). Using a random number as a gate is easier than
measuring/throttling the rate that you're logging at.

~~~
m12k
Also, if we ignore for a moment how hacky it is to implement throttling like
this - why would someone write

    
    
       if(!((_ok) ? true : (Math.random() > 0.1))) 
    

when you could use

    
    
       if(!(_ok || Math.random() > 0.1)) 
    

or just

    
    
       if(!_ok && Math.random() < 0.1)
    
    ?

~~~
aquarion
Because Math.random's expensive and you don't want to execute it unless you're
sure.

~~~
drharris
Expensive only really matters in a loop. And this logical operator would short
circuit anyway.

------
ColinWright
Discussion: <https://news.ycombinator.com/item?id=5788975>

------
russelluresti
My imagination of how this happend:

One Evening, Close to 5:

Boss: "I see we're getting quite a few exception reports in the code."

Developer: "Yeah, working on that. I just need a bit of time."

Boss: "Well, I want to see at least 10% fewer exceptions by tomorrow morning."

Developer: "..."

Next Morning:

Boss: "So I took a look at the reports this morning. Glad to see the number of
exceptions are down."

Developer: "..."

Probably got a raise.

------
klibertp
Now _this_ is where the comment should be!

------
300bps
I can't figure out why some developers love writing lines of code like that.
It's like they think there is a cost for every line of code so they attempt to
use the fewest lines possible while making their intent difficult to discern
without comments.

I had a young developer work for me that did this all the time. He was
actually quite brilliant - but he would put sometimes 20 statements into one
line of code that would scroll past the end of the screen. It was difficult to
discern intent but even worse it was impossible to debug. I asked him several
times if he was taking his programming style from:

<http://thc.org/root/phun/unmaintain.html>

~~~
notdonspaulding
`but he would put sometimes 20 statements into one line of code`

This is why Python's PEP8 recommends an 80 char limit on line length. Not
because at column 81 the code magically becomes more complicated, but because
if you're struggling to make it all fit on one line, it's probably a good sign
that you need to factor out some complexity.

Although you could certainly still write extremely terse (read: unreadable)
code with less than 80 chars per line.

------
cnivolle
<http://omg2.thedailywtf.com> could validate this.

