|
Jonnty posted:Is there any conceivable reason why you might think that was in any way sensible? Some standard return format or something? When you find 2 lines with horrors in a 3 line function, and notice the third line is a return statement, you kinda just assume it might be horror-free.
|
# ? May 14, 2010 16:03 |
|
|
# ? May 14, 2024 05:22 |
|
the guy who does code:
|
# ? May 14, 2010 16:11 |
|
Standish posted:the guy who does It gets rid of the default NULL value for the string which can be useful in some languages.
|
# ? May 14, 2010 16:25 |
|
Sprawl posted:It gets rid of the default NULL value for the string which can be useful in some languages.
|
# ? May 14, 2010 16:26 |
|
Ugg boots posted:When you find 2 lines with horrors in a 3 line function, and notice the third line is a return statement, you kinda just assume it might be horror-free. Excuse my stupid question, but is the horror just not using fmod? Not knowing about a poorly-named function doesn't seem like a horror to me, just a lack of familiarity with the standard library which ought to be corrected. I don't think I would blame someone for reimplementing atan2 either, given its name.
|
# ? May 14, 2010 17:22 |
|
ColdPie posted:Excuse my stupid question, but is the horror just not using fmod? Not knowing about a poorly-named function doesn't seem like a horror to me, just a lack of familiarity with the standard library which ought to be corrected. I don't think I would blame someone for reimplementing atan2 either, given its name. The while blah doesn't really bother me because it at least makes sense intuitively. This makes me cry though: return toDegrees(toRadians(degrees)); Edit: I just realized that this code doesn't work like fmod. The range of the function is [0, 360] not [0, 360)
|
# ? May 14, 2010 19:24 |
|
Ugg boots posted:When you find 2 lines with horrors in a 3 line function, and notice the third line is a return statement, you kinda just assume it might be horror-free. I'm not criticising you for missing it, I'm trying to work out what sort of logic the guy was using. Anybody?
|
# ? May 14, 2010 20:04 |
|
ColdPie posted:I don't think I would blame someone for reimplementing atan2 either, given its name. I would. The C standard library is really small. If you don't know C well enough to be able to use documentation when you want a really common function, you don't know it well enough to be getting paid to write code in it.
|
# ? May 14, 2010 20:11 |
|
Avenging Dentist posted:I would. The C standard library is really small. If you don't know C well enough to be able to use documentation when you want a really common function, you don't know it well enough to be getting paid to write code in it. code:
|
# ? May 14, 2010 20:15 |
|
Avenging Dentist posted:I would. The C standard library is really small. If you don't know C well enough to be able to use documentation when you want a really common function, you don't know it well enough to be getting paid to write code in it. So you'd argue that the library is small enough to just be memorized? I guess I don't disagree. It just seems harsh to me to call it a horror when someone isn't familiar with non-obvious functions like atan2 and fmod.
|
# ? May 14, 2010 20:24 |
|
ColdPie posted:So you'd argue that the library is small enough to just be memorized? I guess I don't disagree. It just seems harsh to me to call it a horror when someone isn't familiar with non-obvious functions like atan2 and fmod.
|
# ? May 14, 2010 20:31 |
|
Yeah really, if your knowledge of C is so limited that you don't think "oh hey there's a math.h header I wonder if it has this seemingly-common function I want", you really have no business writing C.
|
# ? May 14, 2010 21:01 |
|
Here's a coding horror I wrote some time ago that I stumbled on yesterdaycode:
Luckily when I deleted it no errors popped up, so I guess I never actually used it for anything.
|
# ? May 14, 2010 21:20 |
|
Otto Skorzeny posted:This is exactly the sort of trash Perl and Ruby were made to replace
|
# ? May 15, 2010 20:27 |
|
Shumagorath posted:My hate for shell script knows no bounds. Back in second year we were asked to make a baby version of Make using Bash and I got marks taken off for calling the script recursively to process dependencies. I got bitten the other day by the fact that you can't put spaces around an = when assigning variables in bash. Seriously bash, what the gently caress? I then went on to write some scripts in PHP instead which is a horror in itself
|
# ? May 16, 2010 05:10 |
|
ColdPie posted:Excuse my stupid question, but is the horror just not using fmod? The real horror is actually having to use fmod.
|
# ? May 17, 2010 23:09 |
|
code:
|
# ? May 18, 2010 15:43 |
|
You mean ==? I'm not sure how that even works without a compiler/parse error. But hey even long veterans mix up =/== sometimes when not paying attention and they can be a bitch to find. I blame no language since C having the balls to go back to using := for assignment for visual distinction.
|
# ? May 18, 2010 17:01 |
|
NotShadowStar posted:I'm not sure how that even works without a compiler/parse error. That's a perfectly legitimate construct in nearly every language with remotely C-like syntax.
|
# ? May 18, 2010 17:06 |
|
NotShadowStar posted:You mean ==? I'm not sure how that even works without a compiler/parse error. But hey even long veterans mix up =/== sometimes when not paying attention and they can be a bitch to find. I blame no language since C having the balls to go back to using := for assignment for visual distinction. I really used to like my graphing calculator which used "->" as its assignment operator, e.g. code:
code:
|
# ? May 18, 2010 17:16 |
|
clockwork automaton posted:
A static analysis tool might have caught that, but you can't possibly tell me you've never made an == vs = mistake.
|
# ? May 18, 2010 17:24 |
|
crazyfish posted:A static analysis tool might have caught that, but you can't possibly tell me you've never made an == vs = mistake. GCC and Clang both print warnings if you use -Wall. If you don't use -Wall, you are an idiot. code:
|
# ? May 18, 2010 17:34 |
|
Actually I've been noticing a trend lately, and I think it started with Python people where they use assignment all in one line with no spaces likecode:
code:
Of course if your language is cool you could use a little used unicode greek character to really gently caress with people, this would be cool if you could use the c preprocessor to do so. onthing ͼ another
|
# ? May 18, 2010 18:45 |
|
NotShadowStar posted:Actually I've been noticing a trend lately, and I think it started with Python people where they use assignment all in one line with no spaces like I have never seen Python code which doesn't space out assignments, and the standard formatting guidelines say that the '=' operator should have spaces around it. Some people don't put spaces around '=' for keyword arguments, but they're dumb.
|
# ? May 18, 2010 19:13 |
|
clockwork automaton posted:
I make mistakes like this when I code very tired and/or very drunk. I catch it pretty quickly tho, because obviously assignment doesn't happen. The horror here is that this person never caught it and it didn't generate any bugs in the code, presumably because he didn't catch it right away, which indicates that there was no reason to do assignment and have a chance to make this mistake in first place.
|
# ? May 19, 2010 02:39 |
|
I was refactoring some code one day and saw:code:
|
# ? May 19, 2010 03:04 |
|
lumberjack4 posted:I was refactoring some code one day and saw: This can happen if you originally were doing something in one of the clauses and have since removed that behavior.
|
# ? May 19, 2010 07:01 |
|
Janin posted:Some people don't put spaces around '=' for keyword arguments, but they're dumb. code:
|
# ? May 19, 2010 07:32 |
|
Scaevolus posted:From PEP8: Calling people dumb for using a given style and following a standard blindly are both horrors. Your responsibilities as a developer are to do something sane, be consistent about it, and let others do the same. How much horrible bickering would go away if people didn't fight over arbitrary style preferences?
|
# ? May 19, 2010 08:24 |
|
That's why there isn't a fight in Python: there's a style guide. Like all style guides, it provides rules that should be followed unless you have an excellent reason not to. Given this, why is "following a standard blindly" a horror? If you can't be bothered to think about whether you should break a rule, the least confusing thing to do is follow the rule.
|
# ? May 19, 2010 09:19 |
|
pokeyman posted:That's why there isn't a fight in Python: there's a style guide. Like all style guides, it provides rules that should be followed unless you have an excellent reason not to. Using incorrect indentation and meaningless variable names are bad practices that are worth discouraging. That's what I mean by "be sane". But a guide shouldn't be twice as long as it needs to be so it can encompass things like whether a syntactically unimportant space belongs somewhere or not. It doesn't make sense to say that one has an excellent reason to prefer Pink Floyd to Led Zeppelin, it's personal and subjective. People who don't like music or who don't like making decisions or forming opinions for themselves can follow someone else's guideline, but others should not have to explain themselves for having their own sense of style.
|
# ? May 19, 2010 09:47 |
|
A A 2 3 5 8 K posted:It doesn't make sense to say that one has an excellent reason to prefer Pink Floyd to Led Zeppelin, it's personal and subjective. No, you are wrong [1]. We are talking about style guides here, not music. People do not come with a built-in preference for what they consider good style. The preference is mostly "what they are used to." And thus it makes sense to have and to follow style guidelines, so that everybody is used to the same style. [1] Also, I am right.
|
# ? May 19, 2010 09:58 |
|
shrughes posted:No, you are wrong [1]. We are talking about style guides here, not music. All Glory to PEP8
|
# ? May 19, 2010 11:23 |
|
Scaevolus posted:From PEP8: quote:The most popular way of indenting Python is with spaces only. The second-most popular way is with tabs only. Code indented with a mixture of tabs and spaces should be converted to using spaces exclusively.
|
# ? May 19, 2010 13:04 |
|
Fehler posted:What the gently caress? Why would anybody in their right mind encourage space indentation? Because then your code doesn't look all retarded if someone uses different tab sizes than you when they view it, and any decent text editor/IDE nowadays will treat a contiguous block of spaces as if it were a tab anyway, so you can't even tell the difference while you're editing. There's no reason to prefer tab indentation over space indentation nowadays, unless you're worried about MY DISK SPACE
|
# ? May 19, 2010 13:36 |
|
Flobbster posted:Because then your code doesn't look all retarded if someone uses different tab sizes than you when they view it, and any decent text editor/IDE nowadays will treat a contiguous block of spaces as if it were a tab anyway, so you can't even tell the difference while you're editing. The entire point of using tabs is so that it'll look different if somebody changes their editor's tab size. Some people like 2-space indentation, some people like 8-space; tabs let them both use whatever size they want. If your editor treats a block of spaces like tabs, that's the horror.
|
# ? May 19, 2010 14:29 |
|
Tabs vs. spaces: the most important argument in the world.
|
# ? May 19, 2010 14:42 |
|
Janin posted:The entire point of using tabs is so that it'll look different if somebody changes their editor's tab size. Some people like 2-space indentation, some people like 8-space; tabs let them both use whatever size they want. I was reading Crockford's javascript guides and saw this in his style guide: quote:Use of tabs should be avoided because (as of this writing in the 21st Century) there still is not a standard for the placement of tabstops. and facepalmed irl because way to miss the loving point, man.
|
# ? May 19, 2010 14:59 |
|
Janin posted:The entire point of using tabs is so that it'll look different if somebody changes their editor's tab size. Some people like 2-space indentation, some people like 8-space; tabs let them both use whatever size they want. That's create, excecpt how do you format this: code:
|
# ? May 19, 2010 15:05 |
|
|
# ? May 14, 2024 05:22 |
|
With spaces, because that is not indentation.
|
# ? May 19, 2010 15:11 |