coworker rants

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
spdqbr
Posts: 171
Joined: Sat Mar 08, 2008 1:41 am UTC
Location: A shaker of salt

coworker rants

Postby spdqbr » Wed Mar 17, 2010 5:01 am UTC

If this isn't the right place, please feel free to move it.

I would like to take this opportunity to open the door for rants about coworkers / co-coders and others that you are generally a little tired of dealing with. If you need to vent, please feel free.

[Disclaimer] While you are free to post as you like, if you piss off anyone at your work I take no responsibility for that... In other words, vague is good[/Disclaimer]

I'm not the best of the best, I'm not a guru, I've got a lot to learn about a lot of things. Not a day that goes by that I don't learn something new about better ways to do things. I can almost always look back on my code a week later and say to myself, "Wow, that was really not the right way to do that" about something. That said, I feel that I fit in my line of work, and that I do it pretty well. At the end of the day though, some people simply aren't programmers.

I would like to start with an example. I've been coding java for work for about 2 years. This guy has been there a little longer than I have. This is my first coding job, and his second... He is what I've deemed a "Copy-paste coder." He is completely incapable of coding something from scratch without an example, but once provided a similar-enough example he is able to modify it to do what he mostly wants it to. He will copy and paste everything, you'll end up with variable names and method names that make no sense in the context of the code because he's copied the signatures from an example. I think this lends to his complete inability to debug. I swear he spent half an hour debugging this before he called me over to his desk to see if I could figure out where his null pointer exception was coming from:

Code: Select all

    String[] myStrings = new String[];
    for(int i = 0; i < myStrings.length; i++){
        if(myStrings[i].contains("e")){
            System.out.println("It has e!");
        } else {
            System.out.println("It does not have e!");
        }
    }


I'll leave my commentary on why this fellow shouldn't be allowed to code by this startling revelation he came up with a few days ago.
Why don't we just make all our methods & variables static? Then we never have to bother with creating an instance to use them!

Another gent has been around almost as long. He is generally better and less bothersome then the first guy, but he still has his moments. Yesterday he asked me to take a look at some code that was throwing a mysterious ClassCastExcpetion:

Code: Select all

  String str = someCustomClass.getStringValue(someKeyValue);
  // 2 -3 lines of code
  Object o = (Object) str;
  // 2 -3 lines of code
  Hashtable ht = (Hashtable) o;

I had explained to him a few hours earlier that if he had a Hashtable that he had to move around as an Object (because of the way the third party CustomClass mentioned above was implemented), he could just cast it back to a Hashtable...

I shall digress, for now, though I could go on much much longer.

Just remember, these guys are being paid to write (mostly java) code.

Please help me understand that I'm not alone in my pain! Share your stories and vent your frustrations!
In questions of science, the authority of a thousand is not worth the humble reasoning of a single individual.

Galileo

wozub
Posts: 35
Joined: Fri Aug 28, 2009 2:17 pm UTC

Re: coworker rants

Postby wozub » Fri Mar 19, 2010 3:22 pm UTC

What's that string thing trying to do? I don't know any Java but wouldn't <str>.contains look through the whole string? Why does he even need a loop?

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: coworker rants

Postby Berengal » Fri Mar 19, 2010 7:54 pm UTC

He's got a string array.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: coworker rants

Postby Pesto » Fri Mar 19, 2010 10:58 pm UTC

A co-worker was working on a class, and at some point copy-pasta'd it to make some changes. Now there are references to the two different classes, which both have the same name, in several different places in the code base. We were looking at cleaning this up, and I asked her, "Do both these classes have the same interface?"

She said, "What do you mean?"

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: coworker rants

Postby Berengal » Fri Mar 19, 2010 11:38 pm UTC

I saw a poory implemented rose-tree called "CompactTree", presumably because it used arrays to store the (direct) children (through several layers of indirection). It's not so much the tree itself that bothers me, but the fact that time was wasted on creating it, that there was no indication of what use it would serve and no hint as to why any other tree implementation wouldn't suffice.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
spdqbr
Posts: 171
Joined: Sat Mar 08, 2008 1:41 am UTC
Location: A shaker of salt

Re: coworker rants

Postby spdqbr » Fri Apr 09, 2010 4:43 am UTC

Hot off the presses. The same guy as in the first example from the first post and I were making some changes to a message object. There is an instance variable called messageType (a String), all we needed to do was send a message to check the availability of our server, so I suggested just using a new value, "PING_MESSAGE" here. I figured this is a pretty simple change, and I can let turbo over there take care of it, making sure to mention that it would be a poor choice to hard code that string everywhere and much better practice to instead create a static final field called MESSAGE_TYPE_PING. This is right in line with how the other message types were defined. I think this is where I screwed myself. After a solid hour of working on it this is what he came to me with to ask why it wasn't working:

Code: Select all

public class OurMessageClass{
...
  public static final String MESSAGE_TYPE_PING = null;
...
  public OurMessageClass(String messageType){
    if(messageType == "PING_MESSAGE"){
        MESSAGE_TYPE_PING = "PING_MESSAGE";
    }
    this.messageType = messageType; // this was the only thing in the constructor before he got a hold of it
  }
...
}


There is so much wrong with that I didn't know where to start. And it gets better. Clearly we're still having issues with what the hell "static" actually means... and "final" for that matter. This is the server side implementation to see if we received a ping message:

Code: Select all

...
  if(ourMessageClassInstance.MESSAGE_TYPE_PING != null && ourMessageClassInstance.MESSAGE_TYPE_PING == "PING_MESSAGE"){
    // Handle the ping message
  }
...


What is this? I don't even. :?
In questions of science, the authority of a thousand is not worth the humble reasoning of a single individual.

Galileo

Indefinity
Posts: 87
Joined: Thu Dec 24, 2009 7:49 pm UTC

Re: coworker rants

Postby Indefinity » Sun Apr 11, 2010 11:53 pm UTC

See I don't mind the bad coders terribly much. I call it job security.

We have a guy at work that has been coding for probably as long as I've been alive. When someone asked him why he was using an array list in one place instead of, say, a hash map, he asked, "What's the difference? I haven't really worked with maps before." Apparently data structures was not this guy's strong suit. (For the record, he was checking the for the existence of something in the list, which was quite large, and this check was called a LOT.)

I've also had a problem where other coworkers, who are much more senior than I, will have to make their app communicate with ours through a web service, and half the time I end up having to teach them web services myself.

And don't forget the people who are lost without IDEs. I do believe that something like Eclipse can help manage large programs much better than having a bunch of files opened in vi, but you should understand how things are put together behind the scenes.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: coworker rants

Postby Berengal » Mon Apr 12, 2010 1:56 am UTC

Indefinity wrote:See I don't mind the bad coders terribly much. I call it job security.
And I call it stealing my wages and muddling my reputation, not to mention getting in my way. Sometimes I wonder how many companies could get by with one or two decent cowboy coders, wasting no effort on ceremony or due process but still keeping the systems at an acceptable level of spaghetti, instead of the armies of monkeys some have today where each body produces on average one fiftieth of the cowboy coders' output.

Slightly OT, but more seriously, what does make me about fifty times as efficient at home as I am at work? Anyone else also notice this?
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: coworker rants

Postby TheChewanater » Mon Apr 12, 2010 3:17 am UTC

Berengal wrote:Slightly OT, but more seriously, what does make me about fifty times as efficient at home as I am at work? Anyone else also notice this?

I don't actually "work" as in at a job, but I'm way better at home than at school or robotics or something.

Speaking of robotics, I have one from there. At our FRC team, we have two programmers. We both made a drive train class for some reason. Mine actually worked. His used floating point == comparison, which does funny stuff when you're controlling motors.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

Indefinity
Posts: 87
Joined: Thu Dec 24, 2009 7:49 pm UTC

Re: coworker rants

Postby Indefinity » Mon Apr 12, 2010 3:31 am UTC

Cowboy coding is fine when 1) you have a decent skill set, and 2) when you know the full problem at hand. If you're coding at home, both are probably pretty well set. However, in the workplace, #2 is quite hard to satisfy, hence the process, even with coders that are quite competent. I'm not saying that most of the "real world" stuff isn't over-processed, but trying to change "acceptable spaghetti" later on because requirements changed will probably take just as long as the initial process. At work, we have 2 people focusing on a single part, and while we don't bother with real formal specs and design docs, we do have a set process to ensure that the code we write will actually appear somewhat sensible a few months from now when our boss is sure to have us change large parts of it.

Speaking of large changes, our boss recently revealed to us how she had been hiding the fact that she knew our customer's requirements would radically change in a few months, in hopes that "it would just go away." Needless to say, it didn't.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: coworker rants

Postby Berengal » Mon Apr 12, 2010 4:01 am UTC

I try to keep my code very open to changes, particularly because I'm fond of exploratory programming, and that means the "requirements" change all the time. My code is a hedge: Organically grown and neatly trimmed. At home that is. At work it's very hard to do, both because of technology choice (Java, no REPL) and the environment (production databases and webservices everywhere!), so my designs tend to be more static at work than at home. Often though, that's fine, because the requirements are static one-offs as well. So I don't buy your requirement argument. I could go for the technology bit, or simply the fact that you're touching other people's code.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

Notch
Posts: 318
Joined: Tue Dec 12, 2006 5:52 pm UTC
Location: Stockholm, Sweden
Contact:

Re: coworker rants

Postby Notch » Mon Apr 12, 2010 9:05 am UTC

Yes, agile is the way to go, both in terms of project management and coding style!

My worst coworker experience ever was a "java guru" (jguru.com), employed for his amazing java powers. He wasted weeks of our time setting up some architecture that would enable us to make deep copies of data structures to pass around, for some reason. None of this was ever needed, nor will it ever be needed by anyone ever, but we sure did end up with a lot of classes and interfaces. He singlehandedly destroyed all patience I've ever had for any so called "experts".

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: coworker rants

Postby Pesto » Mon Apr 12, 2010 8:12 pm UTC

Notch wrote:Yes, agile is the way to go, both in terms of project management and coding style!

:x

I've yet to drink the agile cool-aid. Granted, I know it's being done wrong where I'm currently working, but I still think it's going to be a fad that will pass.

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: coworker rants

Postby Steax » Mon Apr 12, 2010 11:09 pm UTC

Pesto wrote:
Notch wrote:Yes, agile is the way to go, both in terms of project management and coding style!

:x

I've yet to drink the agile cool-aid. Granted, I know it's being done wrong where I'm currently working, but I still think it's going to be a fad that will pass.


I've been using the agile model for a long time before even realizing it, so I think it's more than a fad. More like a philosophy while coding. It can get tougher when working on teams, though, and an agile programmer working with a non-agile one probably won't get along very well...
In Minecraft, I use the username Rirez.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: coworker rants

Postby Pesto » Mon Apr 12, 2010 11:28 pm UTC

I'm not saying it can't work. There are clear examples where it works quite well. I just think that the constructs of agile, and those constructs that produce quality code within an organization are orthogonal in general.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: coworker rants

Postby Berengal » Tue Apr 13, 2010 3:33 am UTC

Indeed, the constructs that produce quality code is simply good programmers. Robust and maleable are two things Agile does promote a little though, and it's what I aim for when I code. I've always seen agile as more of a project methodology than something directly applicable to pure coding. Since test driven development is put under the agile wing though, and TDD does promote that, I suppose I have to give agile a little cred. The hacker inside me refuses to acknowledge that he's using any methodology when coding though, except maybe type driven development, which is a term he's had to invent himself-ish, and which certainly doesn't work in Java.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: coworker rants

Postby Pesto » Tue Apr 13, 2010 4:14 am UTC

We're going wonderfully off topic, so I started a new thread.

viewtopic.php?f=11&t=59062

Replies about agile can go there.

User avatar
spdqbr
Posts: 171
Joined: Sat Mar 08, 2008 1:41 am UTC
Location: A shaker of salt

Re: coworker rants

Postby spdqbr » Sun May 09, 2010 2:22 am UTC

I'm now tasked with overhauling one of our oldest apps. It's all coded in java 1.3 and running on an app sever that's been end-of-lifed since before I entered college. I was going through for just some basic code clean up when I came across this gem:

Code: Select all

/**
 * This method will replace string containing letters A to L to 1 add
 * convert result to number.
 *
 * @param qty
 *            String containinh A to L
 * @return translated string into integer.
 */
private int translateToNumber(String qty) {
   String charset = "ABCDEFGHIJKLMNOPQRSTU";
   if (qty == null || qty.equals(""))
      return 0;
   for (int i = 0; i < charset.length(); i++)
      qty.replace(charset.charAt(i), '1');
   return new Integer(qty).intValue();
}


A few things about this snippet:
1. It's commented, which is surprising.
2. The comment makes no sense as far as I can discern.
3. The only thing this code can do is
a) throw NumberFormatException
b) return 0
c) return the string you sent it as an int, if the string qualifies as an int
4. It is called in multiple places in the code
5. This has been in our production code, exactly as it is, for 6 years
6. It was put there by my (now) boss

If anyone has any idea as to what it's supposed to do, I'd love to hear your theories.
In questions of science, the authority of a thousand is not worth the humble reasoning of a single individual.

Galileo

User avatar
Xanthir
My HERO!!!
Posts: 5413
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: coworker rants

Postby Xanthir » Sun May 09, 2010 3:17 am UTC

If you feed it "123L4", does it return 12314?

It's *supposed* to, for some reason, replace any capital letters A-U in the string with "1", and then convert the result to a number. The comment is hard to understand due to horrible grammar and a misspelling ("add" instead of "and").

Figuring out *why* the function does this is left as an exercise for the reader.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
spdqbr
Posts: 171
Joined: Sat Mar 08, 2008 1:41 am UTC
Location: A shaker of salt

Re: coworker rants

Postby spdqbr » Sun May 09, 2010 3:51 am UTC

Agreed, Xanthir, the question I asked was not necessarily the question I wanted to ask. Input "123L4" should throw NumberFormatException due to the incorrect usage of String's replace method. Replace spits out a new String with the requested replacement, but does not modify the original, so the line "qty.replace(charset.charAt(i), '1');" doesn't actually do anything.

Even in the context of our business, what we do, and what this particular system does I can think of no compelling reason to have this method do what it looks like it was trying (unsuccessfully) to do.
In questions of science, the authority of a thousand is not worth the humble reasoning of a single individual.

Galileo

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: coworker rants

Postby Pesto » Sun May 09, 2010 10:08 pm UTC

I got called in today (Sunday :x ) to work on a big bug. I'm working with my team's tech lead (who wrote the bug), and had the following conversations.

Her: "Check if the line is longer than 1024 bytes"
Me: "Yep, it's over 2000 characters"
Her: "I don't understand what that means"
Me: "A character is a byte"

A couple minutes later.

"What does the star do in this regular expression?"

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: coworker rants

Postby TheChewanater » Sun May 09, 2010 10:43 pm UTC

Pesto wrote:Me: "A character is a byte"

Not all characters are single bytes.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
Pesto
Posts: 737
Joined: Wed Sep 05, 2007 5:33 pm UTC
Location: Berkeley, CA

Re: coworker rants

Postby Pesto » Sun May 09, 2010 10:48 pm UTC

These are ASCII csv files.

User avatar
TheChewanater
Posts: 1279
Joined: Sat Aug 08, 2009 5:24 am UTC
Location: lol why am I still wearing a Santa suit?

Re: coworker rants

Postby TheChewanater » Sun May 09, 2010 10:54 pm UTC

Oh, okay.
ImageImage
http://internetometer.com/give/4279
No one can agree how to count how many types of people there are. You could ask two people and get 10 different answers.

User avatar
spdqbr
Posts: 171
Joined: Sat Mar 08, 2008 1:41 am UTC
Location: A shaker of salt

Re: coworker rants

Postby spdqbr » Tue May 11, 2010 12:44 am UTC

Speaking of, I went around and around with a guy who couldn't understand why one of our 3rd party apps was writing files that were twice as big as what they "should" be. The concept of Unicode characters was far beyond him.
In questions of science, the authority of a thousand is not worth the humble reasoning of a single individual.

Galileo

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: coworker rants

Postby Cosmologicon » Tue Jun 29, 2010 2:25 pm UTC

It took me 15 minutes to figure out what this does:

Code: Select all

k = tuple(map((lambda x,y: y), *([iter(items[1:separator])]*2)))
v = tuple(map((lambda x,y: y), *([iter(items[separator+1:])]*2)))

and replace it with this:

Code: Select all

k = tuple(items[2:separator:2])
v = tuple(items[separator+2::2])

I'm glad to be working in Python. I'm sorry, functional-programming advocates. Things like this are making me hate your paradigm. >_<

User avatar
Xanthir
My HERO!!!
Posts: 5413
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: coworker rants

Postby Xanthir » Tue Jun 29, 2010 2:37 pm UTC

That's not functional programming, it's intentional obfuscation. The map() is just in there by coincidence; don't blame it, it's not it's fault. That's... horrifying.

I'm not entirely certain your simplification is equivalent, though. On the other hand, I'm still not entirely certain what the first code does without running it a few times.

It *looks* like the first code is slicing from 1:separator, then casting it into an iterator for no good reason, then putting it in a list and duplicating it before always selecting the elements of the second list.

Oh... oh god. Is it casting the slice into an iterator so that there are then two iterators running over the same data, so that the lists contain alternating members of the original slice?

If so, then fuck the author of that code. Just... just fuck him. I'm back on the "intentional obfuscation" train. Seriously, exploiting *side effects* of iterators in order to get every second element of a slice? That's fucking disgusting, and he's going to hell.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: coworker rants

Postby Cosmologicon » Tue Jun 29, 2010 2:51 pm UTC

Okay okay, I don't *hate* functional programming. But we run pylint on production code (which this is not), and by default it gives a warning for every use of "map". At first it seemed ridiculous to exclude a feature of the language like that, but now I'm tending to agree.

User avatar
Xanthir
My HERO!!!
Posts: 5413
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: coworker rants

Postby Xanthir » Tue Jun 29, 2010 3:48 pm UTC

Again, though, the map's not the problem. He's just using it as a tool to force iter() to evaluate in the order he wants. This is like murdering someone with a screwdriver - sure, the screwdriver made it easier than just using your hands, but it's not the screwdriver's fault you murdered someone.

The evil part is using iter() like that and depending on evaluation order in such a fashion. That's just plain disgusting. He should have his pay docked for an abuse like that. Even if he somehow didn't realize that you could put a step argument in a slice, there are still several reasonably correct ways to do it that require *way* less thinking to come up with, let alone understand later.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: coworker rants

Postby Berengal » Tue Jun 29, 2010 7:54 pm UTC

Note that `map(foo, *bar) == map(foo, zip(*bar))'.
I drew a flowchart (in no recognizable flowchart markup). It should be clear that the evilness is not in the map, but in the implicit zip (made explicit for your viewing pleasure) and the exploitation of the side effects of an iterator.
flowchart.png
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: coworker rants

Postby Cosmologicon » Tue Jun 29, 2010 8:05 pm UTC

Yes, I understand (although, it's because I understood the code to begin with, not because I really follow your flow chart that well). I shouldn't have made it a functional rant. I take it back.

I have seen what I believe to be a myopically functional programming mindset resulting in bad Python, but I agree this isn't a good example of it. My apologies.

User avatar
Berengal
Superabacus Mystic of the First Rank
Posts: 2707
Joined: Thu May 24, 2007 5:51 am UTC
Location: Bergen, Norway
Contact:

Re: coworker rants

Postby Berengal » Tue Jun 29, 2010 8:17 pm UTC

The flowchart was more for my own benefit, and then I felt like sharing, so there.

Also, any functional programmer worth his salt would never even consider using iterator side-effects for anything. Iterators are for traversing something once.
It is practically impossible to teach good programming to students who are motivated by money: As potential programmers they are mentally mutilated beyond hope of regeneration.

User avatar
Xanthir
My HERO!!!
Posts: 5413
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: coworker rants

Postby Xanthir » Tue Jun 29, 2010 9:49 pm UTC

Right; the problem came from a fundamentally un-functional approach to the problem in the first place. ^_^

Lesson learned: your coworker is an idiot. That is all.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Izawwlgood
WINNING
Posts: 18686
Joined: Mon Nov 19, 2007 3:55 pm UTC
Location: There may be lovelier lovelies...

Re: coworker rants

Postby Izawwlgood » Tue Jun 29, 2010 11:13 pm UTC

Can non-comp sci coworker rants go here too?
... with gigantic melancholies and gigantic mirth, to tread the jeweled thrones of the Earth under his sandalled feet.

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: coworker rants

Postby Cosmologicon » Wed Jun 30, 2010 12:41 am UTC

Xanthir wrote:I'm back on the "intentional obfuscation" train. Seriously, exploiting *side effects* of iterators in order to get every second element of a slice? That's fucking disgusting, and he's going to hell.

I don't know, the more I think about it, the less I feel like this is "exploiting a side effect of iterators". I don't see anything fundamentally wrong with calling an iterator via two or more references. I've never done it, but I can see situations where it would be appropriate. And in that case, advancing the iterator with each call would be the expected behavior, not a side effect.

No, the real WTF is just that this is about the worst possible way to do what the code does. Everyone can tell that the best way is:

Code: Select all

tuple(map(lambda x:x[1], filter(lambda x: x[0]%2, enumerate(items))))
;)

User avatar
Xanthir
My HERO!!!
Posts: 5413
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: coworker rants

Postby Xanthir » Wed Jun 30, 2010 12:50 am UTC

Cosmologicon wrote:
Xanthir wrote:I'm back on the "intentional obfuscation" train. Seriously, exploiting *side effects* of iterators in order to get every second element of a slice? That's fucking disgusting, and he's going to hell.

I don't know, the more I think about it, the less I feel like this is "exploiting a side effect of iterators". I don't see anything fundamentally wrong with calling an iterator via two or more references. I've never done it, but I can see situations where it would be appropriate. And in that case, advancing the iterator with each call would be the expected behavior, not a side effect.

Sure, there are times when copying around an iterator reference may be appropriate. But doing so solely so you can emulate an iterator slice? Disgusting.

(There's even an itertools.islice, if you've already got an iterator that you need every nth element of. It would be stupid in this case since you're starting from a list and just slice it directly, but still. He reinvented one part of islice in an excessively obfuscated fashion.)
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

Indefinity
Posts: 87
Joined: Thu Dec 24, 2009 7:49 pm UTC

Re: coworker rants

Postby Indefinity » Wed Jun 30, 2010 1:49 am UTC

Izawwlgood wrote:Can non-comp sci coworker rants go here too?

I feel that any amount of incompetence (real or perceived) can go here :)

User avatar
Arancaytar
Posts: 1642
Joined: Thu Mar 15, 2007 12:54 am UTC
Location: 52.44°N, 13.55°E
Contact:

Re: coworker rants

Postby Arancaytar » Wed Jun 30, 2010 11:43 am UTC

Cosmologicon wrote:It took me 15 minutes to figure out what this does:

Code: Select all

k = tuple(map((lambda x,y: y), *([iter(items[1:separator])]*2)))
v = tuple(map((lambda x,y: y), *([iter(items[separator+1:])]*2)))

and replace it with this:

Code: Select all

k = tuple(items[2:separator:2])
v = tuple(items[separator+2::2])

I'm glad to be working in Python. I'm sorry, functional-programming advocates. Things like this are making me hate your paradigm. >_<


Poor guy must have Haskell as his first language. Not enviable. :P
"You cannot dual-wield the sharks. One is enough." -Our DM.
Image

fictiveLaark
Posts: 31
Joined: Tue Mar 16, 2010 3:57 am UTC

Re: coworker rants

Postby fictiveLaark » Thu Jul 01, 2010 7:44 am UTC

Is it just me or do many Computer Science majors have Mathematical, Scientific, Logical, sometimes even Computer skills that border on utterly moronic? So many people I've worked with seem to have acquired nothing more than computer buzz words and childish OOP concepts(I like OOP programming by they way, but many people do it very badly) over the course of their education.

There is on guy in particular that I want to beat to a bloody pulp each time he explains the poor performance of a program with,

"The computer needs more cores."

To elaborate,

"The computer needs more cores."
"Why does the computer need more cores?"
"Because Java is highly multithreaded."
"But we're not multithreading."
"But it's Java so it's meant for multiple threads."
"But we're not multithreading."
*Some time later*
"Yeeaah dude, it's definitely the cores."

User avatar
phlip
Restorer of Worlds
Posts: 7572
Joined: Sat Sep 23, 2006 3:56 am UTC
Location: Australia
Contact:

Re: coworker rants

Postby phlip » Thu Jul 01, 2010 7:54 am UTC

Arancaytar wrote:Poor guy must have Haskell as his first language. Not enviable. :P

You wouldn't be able to abuse iterators like that in Haskell... that abuse requires mutable aliased state... zip has two iterators, but when it reads from one, the other advances too, 'cause they're actually the same iterator. From what I understand, Haskell and friends try to avoid that kind of behaviour like the plague.

It took me many reads through to see what it was doing, so for those that are still stuck, plug this into Python and see what it does:

Code: Select all

l = [1,2,3,4,5,6]
a = iter(l)
zip(a,a)
The rest is just horrific syntax contortions to pass two aliases of the same iterator to zip (well, map, but it's effectively zip) without having to store it in a temp var first.

Code: Select all

enum ಠ_ಠ {°□°╰=1, °Д°╰, ಠ益ಠ╰};
void ┻━┻︵​╰(ಠ_ಠ ⚠) {exit((int)⚠);}
[he/him/his]


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 6 guests