|
code:
Second reaction: oh god IsLocked is a bool...
|
# ? Dec 21, 2009 18:20 |
|
|
# ? Apr 27, 2024 18:04 |
|
meinstein posted:
Lol yea. Good points. It looks like a very bad Java programmer tried to learn C#
|
# ? Dec 21, 2009 18:45 |
|
meinstein posted:
Better yet, that statement will always return false.
|
# ? Dec 21, 2009 19:22 |
|
A novel implementation of str_replace(" ", "", $str):code:
|
# ? Dec 22, 2009 03:45 |
|
Does $ret implicitly get set to "" when something is concatinated to it (and it doesn't already exist).
|
# ? Dec 22, 2009 04:01 |
|
king_kilr posted:Does $ret implicitly get set to "" when something is concatinated to it (and it doesn't already exist).
|
# ? Dec 22, 2009 04:56 |
|
gibbed posted:Yes, but you'll also get a warning (unless you're dumb and have warnings set to something other than E_ALL). ... that's the real coding horror.
|
# ? Dec 22, 2009 06:04 |
|
megalodong posted:A novel implementation of str_replace(" ", "", $str):
|
# ? Dec 22, 2009 16:26 |
|
My AP Computer Science teacher has this awful habit of using nondescript parameter variables, like the following:code:
code:
|
# ? Dec 27, 2009 06:01 |
|
Yakattak posted:My AP Computer Science teacher has this awful habit of using nondescript parameter variables, like the following: I'm guilty of using nondescript variables, but only in situations like so: code:
But it's funny that he asked you why you had descriptive variable names. I've yet to have somebody ask me that.
|
# ? Dec 27, 2009 22:30 |
|
Hardly a coding horror, though. In college (UK college that is, so not university) we did a very simple programming module and my teacher was very strict about using Hungarian notation (ugh). Even for a loop counter he'd use names like intI, intJ and intK. I had no other exposure to programming so when I went to university and realised that hardly anyone uses hungarian notation I was pretty astounded because I assumed it was the way variables were named. It took me a while to get used to reading variable names without prefixes and to stop myself adding them.
|
# ? Dec 28, 2009 02:41 |
|
I'm guilty of nondescript variables in two ways: Loop variables and isolated variables in methods/procedures under 5 lines or so (for example, getters/setters). What's the general opinion on short variable names that are explained/in limited context? code:
|
# ? Dec 28, 2009 17:26 |
|
It's fine until you realize you need to do something else in that loop and suddenly the lines are separated by several other lines of code, then your context can be lost and you have people seeing q = q.filter(firstname__contains='y') all by its lonesome somewhere and wondering WTF q is.
|
# ? Dec 28, 2009 18:19 |
|
Captain Capacitor posted:What's the general opinion on short variable names that are explained/in limited context? I can't promise this is the "general" opinion, but nobody should have a problem with it unless they were uptight and/or unable to determine by context where guidelines do and don't make sense so they rigidly follow and repeat them as often as possible because it's how they judge their worth as a developer. In which case they'd devise a scenario in which these 5 lines of code get pasted into a critical section of a nuclear power plant monitoring system that is maintained by idiots. Almost all guidelines can be replaced by common sense.
|
# ? Dec 28, 2009 19:34 |
|
Captain Capacitor posted:I'm guilty of nondescript variables in two ways: Loop variables and isolated variables in methods/procedures under 5 lines or so (for example, getters/setters). I'm wondering why you do q = query = ... Is it to set the value to both q (local var) and query (object var)? For local variables, I fairly often create objects from the initials of the class name, such as: FlipTransition ft = new FlipTransition(); MemoryStream ms = new MemoryStream(); Some people have gone "uggggh I don't like it", but my coworkers do similar things and for local variables in short functions it tends to not be a problem.
|
# ? Dec 29, 2009 20:33 |
|
chocojosh posted:I'm wondering why you do q = query = ... Is it to set the value to both q (local var) and query (object var)? I assumed he was doing it to make it explicit what q actually is, but giving it the value q as well to avoid having to type it out - attributes don't work like that in Python as far as I know.
|
# ? Dec 29, 2009 20:47 |
|
Captain Capacitor posted:What's the general opinion on short variable names that are explained/in limited context? Your particular example is bad because it would actually be clearer as a single statement. But in general, the answer is "think about what you are doing". The notion that coding style needs hard-and-fast rules is pretty silly (though you should apply them consistently in your code).
|
# ? Dec 29, 2009 21:02 |
|
Haquer posted:I'm guilty of using nondescript variables, but only in situations like so: Using i, j, and k as loop indices has been common practice since Fortran. I don't think anyone would say it's bad.
|
# ? Dec 29, 2009 22:19 |
|
http://search.cpan.org/~bshade/Array-PAT-2.0.0/PAT.pm Array::PAT - PHP Array Tools - Perl extension for array functions that are built into PHP.
|
# ? Dec 29, 2009 22:33 |
|
A A 2 3 5 8 K posted:http://search.cpan.org/~bshade/Array-PAT-2.0.0/PAT.pm Is the horror that they all start with array_?
|
# ? Dec 29, 2009 23:38 |
|
yaoi prophet posted:Is the horror that they all start with array_? The next horror on the list is the inconsistent argument lists.
|
# ? Dec 29, 2009 23:42 |
|
The horror is that someone decided to take horror of PHP and combine it with the horror that is Perl.
|
# ? Dec 29, 2009 23:50 |
|
yaoi prophet posted:Is the horror that they all start with array_? It's a meta-horror of spreading PHP to other languages, see also: http://phpjs.org/
|
# ? Dec 29, 2009 23:59 |
|
A A 2 3 5 8 K posted:http://search.cpan.org/~bshade/Array-PAT-2.0.0/PAT.pm Ahahahahahahahahahahahahahaha
|
# ? Dec 30, 2009 00:33 |
|
A A 2 3 5 8 K posted:http://search.cpan.org/~bshade/Array-PAT-2.0.0/PAT.pm Array::PAT posted:Just as The Beatles say: Forgot about that humdinger. That's from the Yellow Submarine lyrics right?
|
# ? Dec 30, 2009 01:43 |
|
pokeyman posted:Forgot about that humdinger. That's from the Yellow Submarine lyrics right? I thought it might be a copy/paste failure but then I thought of how unlikely that would be coming from a PHP enthusiast.
|
# ? Dec 30, 2009 01:54 |
|
"And in the end, the love you take is equal to the love you pass by value." — John Lennon
|
# ? Dec 30, 2009 01:59 |
|
A A 2 3 5 8 K posted:I thought it might be a copy/paste failure but then I thought of how unlikely that would be coming from a PHP enthusiast.
|
# ? Dec 30, 2009 03:03 |
|
pokeyman posted:Forgot about that humdinger. That's from the Yellow Submarine lyrics right? It's from Love Me Do, but was removed in a later release, as it was only included for compatibility purposes.
|
# ? Dec 30, 2009 03:44 |
|
Mustach posted:"And in the end, the love you take is equal to the love you pass by value." — John Lennon code:
|
# ? Dec 30, 2009 14:02 |
|
Implementing a switch with a for case loop uattack is an int assigned in a loop a couple lines above this, by the way.code:
code:
dis astranagant fucked around with this message at 11:17 on Dec 31, 2009 |
# ? Dec 31, 2009 10:55 |
|
dis astranagant posted:
Which programmer hasn't forgotten to add the horn damage at one point or another?
|
# ? Dec 31, 2009 16:19 |
|
Is this code from Angband or Nethack or a similar roguelike?
|
# ? Dec 31, 2009 16:55 |
|
Senso posted:Is this code from Angband or Nethack or a similar roguelike? Google only turns up an expired pastebin, so it's probably not from a popular OSS project.
|
# ? Dec 31, 2009 17:08 |
|
Looks like it's out of a game called Dungeon Crawl, and yes, it's a Roguelike. There is apparently even an MMO or something. The code snippit looks like it is out of the "stone soup" distro in fight.cc.
|
# ? Dec 31, 2009 18:23 |
|
I'm sure this has been posted somewhere around here before, but I haven't seen it. Spectate Swamp Desktop Search It kind of speaks for itself. He posts a lot and it seems he writes code like this professionally.
|
# ? Dec 31, 2009 20:29 |
|
tombom posted:Spectate Swamp Desktop Search That right there is a proclick! I love the versioning system he's built-in to his file. What language is that? Looks like it would produce horrors no matter the user.
|
# ? Dec 31, 2009 21:50 |
|
Looks like VB to me.
|
# ? Dec 31, 2009 21:59 |
|
tombom posted:I'm sure this has been posted somewhere around here before, but I haven't seen it. Even Ulillillia writes clearer code than that.
|
# ? Dec 31, 2009 23:51 |
|
|
# ? Apr 27, 2024 18:04 |
|
tombom posted:I'm sure this has been posted somewhere around here before, but I haven't seen it. Someone should submit that to TDWTF.
|
# ? Jan 1, 2010 00:08 |