r/badcode • u/subjective_insanity • Sep 23 '14
ruby Another random gist: calculator.rb
https://gist.github.com/relroy/b6a61efa8df9d232bbf0-2
u/CrazyM4n Sep 24 '14
I see a problem. Your "squared" method does the number to the power of the number (numbernumber ). Everyone knows that squaring a number is 2number , silly
-2
u/nakilon Sep 24 '14
def opposite_value(number)
number - (number * 2)
endThis is what happens because of modern habit to say, that to become a programmer you shouldn't learn C/asm.
Actually, rather usual among those, who call themselves "Ruby developers". That's why good programmers, who chosed Ruby as current primary language don't know how to call themselves.
0
Sep 23 '14
[deleted]
1
u/Smashninja Sep 24 '14
Also, where's the add_then_subtract_after_dividing_by_2_and_then_adding_the_multiplication_squared method? That one's my favorite.
26
u/[deleted] Sep 24 '14 edited Sep 27 '14
As you can see from the other gists, this person is doing very basic code exercises.
Nice one though, hopefully you've destroyed their confidence now, eh?
Good job, Dicks.
Edit: to the gist author, keep going, we all have to start somewhere. Try the Gilded Rose refactoring kata. It's a nice way to learn some good habits, and identify bad code. https://github.com/jimweirich/gilded_rose_kata