3 ms·
That beats the 1000 lines inside a single if {} block that I once found. (The conditional in that if {} always evaluated to true).
by ben_w 5y ago
That beats the 1000 lines inside a single if {} block that I once found.
(The conditional in that if {} always evaluated to true).
- moralestapia 5y agoLol, reminds me of the meme: var a = true; if(a == true) then return true; else if(a == false) then return false; Or something like that.
- hibbelig 5y agoI once looked at 30 lines of code, analyzed them and found out that they always computed true, never false. My background knowledge told me that Zeit was the correct value. But I did not dare to eliminate it in the main branch, only in a refactoring branch that I think got never merged. I am not proud.
- asddubs 5y agoi hate to say that I've definitely written code like that. not any time recently, thankfully (at least I think)
- tonyedgecombe 5y agoThe thing is it’s easy to imagine a situation that leads to this. It’s five o’clock on Friday, your partner is hassling you to get home because you have visitors, you are exhausted because you worked 60 hours this week and your boss is breathing down your neck because they want their pet feature finished right now. This is why I’m always loathe to criticise stuff I see on WTF.
- moralestapia 5y agoI could totally conceive places where "you have to write at least N lines of code per day" and then this kind of thing explains itself.
- MBCook 5y agoI have seen that in real code. No kidding.
- deleted 5y ago[deleted]
- Aardwolf 5y agoelse throw "this should never happen";
- LandR 5y agoI've seen this in production code: public static bool ConvertToBoolean(this int number) { var TrueOrFalse = false; if(number != 0) TrueOrFalse = true; return TrueOrFalse; }
- jandrese 5y agoYeah, but the function only had a single exit point, so it was following best practices.
- ben_w 5y agoI don’t remember if it did or didn’t have a single exit point. But the thing as a whole didn’t follow any best practices I’ve ever heard of: the project also had what looked like a bizarre attempt to reimplement the concept of properties(!), in that the UI classes had fixed length arrays of all their subviews, which were accessed by constants. Each section of the UI had its own god class, where different views in that section were all the same class, called with a constructor that determined if a view ought to be created for any given constant. There were also something like 20,000 blank comments. No idea why, the guy who added them didn’t even understand my question: int something = foo(); // double baz = bar(something, 5); That kind of thing. (The project is no longer available and the business who made it has since closed, before anyone asks).
- jandrese 5y agoI was being tongue in cheek about people who religiously follow that "single entry and single exit to any function" rule and then get wrapped around the axle when a function needs to make several discrete sanity checks at the start before doing work.
- ben_w 5y agoFair enough, it’s hard to convey tongue-cheek position in writing ^_^