Wait, What?
github.com
Wait, What?
1–10 of 17 posts
Re: Wait, What?
#2Re: Wait, What?
#3Re: Wait, What?
#4Re: Wait, What?
#5Re: Wait, What?
#6I 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:
Re: Wait, What?
#7Looks 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.
!((_ok) ? true : (Math.random() > 0.1))
_ok ? false : !(Math.random() > 0.1)
!_ok && Math.random()
Seems fine...until you realise that this is the condition to exit early, it's still logging 90% of the time which is almost certainly not the desired behavior.Not to mention _ok is a terrible name for that variable, and it's only ever being used as a negation. Why isn't it called _error or something?
Re: Wait, What?
#8Looks 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.
if(!((_ok) ? true : (Math.random() > 0.1)))
when you could use if(!(_ok || Math.random() > 0.1))
or just if(!_ok && Math.random() Re: Wait, What?
#9Looks 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.
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()
Re: Wait, What?
#10Earlier quoted context omitted.
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()
Because Math.random's expensive and you don't want to execute it unless you're sure.