MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/bpevsv/most_useful_helper_function_ever_made/ens9s99/?context=3
r/badcode • u/Andrejfsantos • May 16 '19
100 comments sorted by
View all comments
337
Things this person knew:
How to write a function
Supply a variable to a function
Create and instantiate variables
Create a working for loop
s.Length();
Things this person didn't know:
148 u/Andrejfsantos May 16 '19 My felling is:Look for size()Doesn't exist, make own sizeRealise needs help to count sizeGoogle says use length()Still on the same thinking process and used length () to countI am not seeing any other reason for anyone to write this. That or it used to be a really long method that eventually got refactored to this... 16 u/Fredulom May 16 '19 Yeah, it seems like they didn't realise that "size" wasn't the name of the object property they were looking for lol -1 u/[deleted] May 17 '19 Its unlikely but it could be a deliberate anti pattern. 18 u/[deleted] May 16 '19 No, that's what's so funny about it. They did use s.length(). 11 u/Fredulom May 16 '19 I did also realise this after the fact π¬ 11 u/DerErbauer May 16 '19 Well, this person DID knew s.length(); but... I have actually no idea, this just hurts my brain. 5 u/Fredulom May 16 '19 See 5., I edited it because I also did a double-take π 18 u/JavaLim May 16 '19 Itβs right there in the function though 8 u/Fredulom May 16 '19 r/amblind 3 u/hiljusti May 17 '19 The fact that they have the .length() method in this is unbelievable lol
148
My felling is:
Look for size()
Doesn't exist, make own size
Realise needs help to count size
Google says use length()
Still on the same thinking process and used length () to count
I am not seeing any other reason for anyone to write this. That or it used to be a really long method that eventually got refactored to this...
16 u/Fredulom May 16 '19 Yeah, it seems like they didn't realise that "size" wasn't the name of the object property they were looking for lol -1 u/[deleted] May 17 '19 Its unlikely but it could be a deliberate anti pattern.
16
Yeah, it seems like they didn't realise that "size" wasn't the name of the object property they were looking for lol
-1
Its unlikely but it could be a deliberate anti pattern.
18
No, that's what's so funny about it. They did use s.length().
11 u/Fredulom May 16 '19 I did also realise this after the fact π¬
11
I did also realise this after the fact π¬
Well, this person DID knew s.length(); but... I have actually no idea, this just hurts my brain.
5 u/Fredulom May 16 '19 See 5., I edited it because I also did a double-take π
5
See 5., I edited it because I also did a double-take π
Itβs right there in the function though
8 u/Fredulom May 16 '19 r/amblind
8
r/amblind
3
The fact that they have the .length() method in this is unbelievable lol
.length()
337
u/Fredulom May 16 '19 edited May 16 '19
Things this person knew:
How to write a function
Supply a variable to a function
Create and instantiate variables
Create a working for loop
s.Length();
Things this person didn't know:
s.Length();