I don't even know where to begin with this



  • Now that we're at the end of a long push to make a release, I've been running the application through JProfile to see what's up. This method is called in the heart of
    a doubly nested loop. It spins through a VERY long list of events to see if they
    qualify for some action.

    It defies description.

      // OP: e - the event that we're processing
      // OP: e.getTheId() - synchronous deeply buried call to db to return a native long
      // OP:              - it does NOT cache the result
      // OP: e.getAttr1() - returns a native long
      // OP: e.getAttr2() - returns: a native int as: ""+((Integer)i).intValue()
      // OP: assume: Map<Long,SomeEnum> m;
      // OP: constants anonymized, but are always numeric
    

    private boolean func(MyEvent e) {
    boolean ans = false;

    // OP: Let's not use a temp here. Just keep going back to the db to get the value each time
    if ("12".equalsIgnoreCase(e.getId()) || "34".equalsIgnoreCase(e.getId()) ||
        "56".equalsIgnoreCase(e.getId()) || "78".equalsIgnoreCase(e.getId())) {
       ans = true; // OP: note how we continue to evaluate stuff anyway
    }
    
    // OP: 18 comparisons: again, don't use a temp: map.containsKey
    if (m.get(e.getAttr1()) == SomeEnum.A || // OP: useless implied calls to Long.valueOf()
        m.get(e.getAttr1()) == SomeEnum.B || // OP: as opposed to using a temp
        ...
        m.get(e.getAttr1()) == SomeEnum.R) { 
       ans = true; // OP: note how we continue to evaluate stuff anyway
    }
    
    // OP: So we repeatedly do: ""+((Integer)i).intValue() and then case insensitive string
    // OP: comparisons in order to avoid doing native int comparisons, as opposed
    // OP: to, I don't know, putting the int's in a map and simply doing one call
    // OP: to: map.containsKey(i)
    if ("1".equalsIgnoreCase(e.getAttr2()) || "2".equalsIgnoreCase(e.getAttr2()) ||
        ...
        "15".equalsIgnoreCase(e.getAttr2()) || "16".equalsIgnoreCase(e.getAttr2())) {
       ans = true;
    }
    
    return ans;
    

    }

    This function is called tens of millions of times for any given run. It turned out it was taking almost 28% of the total run time.

    I don't blame Java for implementing auto boxing, or anything else. I blame people who grew up on this level of language where everything is automatically done for you, and who have no understanding of how things work under the hood.



  • You really don't need under the hood knowledge to see that this code is the equivalent of the furry liquefied remains of pasta sauce you forgot and left in the pan while you were away for an extra long weekend.



  • Insane: given a hard-coded digit string, retreiving a numeric value, converting the numeric value to string, then doing a case-insensitive character by character match just in case one digit is upper case and the other digit is lower case.

    Yeah, computers are powerful, but don't insult them!

    Snoofle, you should write a book.



  • @AndyCanfield said:

    then doing a case-insensitive character by character match just in case one digit is upper case and the other digit is lower case.
     

    Perhaps they wanted it to be Turkish-agnostic.



  • @snoofle said:

    I don't blame Java for implementing auto boxing, or anything else. I blame people who grew up on this level of language where everything is automatically done for you, and who have no understanding of how things work under the hood.

    Aw man. Snoofle baby, I love ya, but why are you repeating this Slashdot shit?

    It's obvious to anybody competent that this code is shit, the presence of automatic memory management and auto-boxing has no relevance here. You shouldn't be decrying Java for having those features, you should be praising Java* for the kind of productivity boosts those features give good developers, for how they enable developers to focus on the actual problem being solved and not spend all their time worrying about losing a few bytes of memory. EVERYBODY should be using modern memory-managed programming languages.

    The problem here is you have shit co-workers, not Java. The secondary problem is Java had shit tools.

    *) Yes I just typed that



  •  @AndyCanfield said:

    Insane: given a hard-coded digit string, retreiving a numeric value, converting the numeric value to string, then doing a case-insensitive character by character match just in case one digit is upper case and the other digit is lower case.

    What, you've never heard of lowercase numerals?

     



  • @Blakeyrat - I wasn't ranting against Java, just my frustration at idiot coworkers. This particular genius was the guy that intially wrote the application, and is now the team lead on another project. Having done (and posted) code reviews on his new project, I can see he's spreading the WTF far and wide.

    Just today, over 20 people are on a conference call since 8AM trying to figure out the daisy chain of dependencies of several projects that need to be deployed. Why? Because his project is AFU because his team forgot to check simple things like: a) do the db tables have the right columns for the release? (some did; he forgot to run some of the scripts) b) is the new data in the tables? (sort of) c) is the new data in the RIGHT tables (no it wasn't), d) do all the pages actually load when you click the links? (no: someone hard coded the url of a development server into something, and so it went.



  • @snoofle said:

    @Blakeyrat - I wasn't ranting against Java,

    Yes you were.

    @snoofle said:

    Just today, over 20 people are on a conference call since 8AM trying to figure out the daisy chain of dependencies of several projects that need to be deployed. Why? Because his project is AFU because his team forgot to check simple things like: a) do the db tables have the right columns for the release? (some did; he forgot to run some of the scripts) b) is the new data in the tables? (sort of) c) is the new data in the RIGHT tables (no it wasn't), d) do all the pages actually load when you click the links? (no: someone hard coded the url of a development server into something, and so it went.

    Look, this is why you bug me: you get into stuff like this and you're perfectly ok with it. Look, if I was in that meeting, I'd take one of two actions: 1) I'd demand the moron wasting hours of everybody's time on a Saturday be fired, or 2) I'd quit. I wouldn't just grin and bear it and go to the same meeting 3 weeks down the road because the actual problems at the company never get fucking fixed and basically that attitude bugs the crap out of me.



  • @snoofle said:

    This function is called tens of millions of times for any given run. It turned out it was taking almost 28% of the total run time.

    Just out of curiosity, without naming a company, can you give some kind of context as to what this application is doing?



  • @blakeyrat said:

    you're perfectly ok with it
    No, it bugs me to no end, BUT a) I'm powerless to do anything about it, in spite of my repeated requests to the powers that be (I've been told to just shut up and stay out of it), and b) I get paid more than double what I made at my last job, and with two kids about to start college... I put up with it (this forum actually helps me vent a lot, and for that I am grateful).



  • I dunno; in your situation I'd have to think about what my dignity was worth.

    I mean I get your reasons, I really do. I just... in the same situation, I don't see myself staying there. Couldn't do it.



  • @blakeyrat said:

    I dunno; in your situation I'd have to think about what my dignity was worth.

    I mean I get your reasons, I really do. I just... in the same situation, I don't see myself staying there. Couldn't do it.

    Maybe this will put it in perspective...

    When I was a young adult, I wanted to make a difference. I took a lower paying job for the opportunity to make the world a better place (it didn't work out that way, but I made the effort). Then I got married and had kids. We still tried to do the right thing, but started shoveling money away for the inevitable big bills down the road. Years passed. Now those bills are barrelling right at us: two college educations, two weddings, two retirements. Don't get me wrong, we've saved a lot. But the past 3 jobs paid so much that I didn't care how f'd up things were, the weekly checks would fund most of the above without dipping into the savings.

    I focus on the college graduations, the weddings and me and my wife sitting on some beach into the sunset, and ignore the nonsense. I mean, in the grand scheme of things, does it really matter if someone put a brace here vs there, reinvented the wheel, used this tool vs that tool, some user did something un-programmer like, or some manager can't manage?

    The older you get, the easier it is to ignore the folly of others. I've said it before; their stupidity and incompetence keeps me (and all of us) employed in what for me has been a very lucrative field. I have the luxury of laughing all the way to the bank.



  • I don't prioritize money as much.



  • @snoofle said:

    Now that we're at the end of a long push to make a release, I've been running the application through JProfile to see what's up.
     

    They didn't find the hat, then? Well played.


     



  • @snoofle said:

    I've said it before; their stupidity and incompetence keeps me (and all of us) employed in what for me has been a very lucrative field. I have the luxury of laughing all the way to the bank.

    IT fat cats. Some day the spotlight will turn on this industry like they did for banksters. Hopefully by then you will be on the beach with your wife like that Korean dude who left Enron before the storm.



  • @snoofle said:

    The older you get, the easier it is to ignore the folly of others.

    Most developers go through several layers of experience in their lifecycle:

    1. tentative steps - get "hello world" working in a completely alien language. Get frustrated at the number of hoops required (additional packages, libraries, dependencies, environment settings) just to compile, link, debug and GET THE FUCKING THING TO RUN.
    2. bigger strides - start adding more lines, even copying out someone else's routine now that the compile-link-cleanup-run process is more familiar
    3. exploratory leaps - what if we start changing this? How can I get it to do that? Let's experiment!
    4. first real program - now the trial's over, sketch out something to do from scratch, but spend more time struggling with the coding and losing focus due to no real clear design process. But finally something is cobbled together... and it works! Result!
    5. maintenance headache - a minor change causes a large impact with more debugging required. Perhaps if we didn't hard-code these values, we could...
    6. improving/polishing - a code snippet shows a better way of doing things, so we begin to pick up tips and look at polishing our newborn to make it shiny!
    7. groupthink - suddenly we're not alone. We join a crowd (a community, a programming class, a development team) and begin to learn from others, learning from their experiences whilst helping others (and laughing at some WTFs encountered).
    8. proper shaping - at some point, some more formalised structure is bestowed upon the way we do things, so we learn best practise, design theory, understand why it should be done that way and the consequences of not. And we sneer at examples of bad code whilst cringing at memories of our own first efforts.
    9. peer reviewing - we review another's code, guide them to best practise, show them the One True Way, explain why it should be done that way.

    I think there's a point at which you've seen so many WTFs you know the antipatterns by heart and can quickly identify them on sight alone, knowing instinctively what remedial course of action is required, and encountering them no longer surprises/shocks you - you've just become too inured by it all. You accept that it's a part of development life because it's present in developers to some degree... you tend to focus upon methods of preventing WTF introduction in the first place.

    Or you wryly accept that you can't affect transformational change overnight, so post the WTFs here in the hope others will learn by it.



  • @blakeyrat said:

    I don't prioritize money as much.
     

    Snoofle's prioritizing the things that need money, such as kids and retirement.

    You go have a kid and find out how much of a time and money sink it is.



  • @dhromed said:

    You go have a kid and find out how much of a time and money sink it is.

    True. Well compensated, though.



  • @snoofle said:

    @Blakeyrat - I wasn't ranting against Java, just my frustration at idiot coworkers. This particular genius was the guy that intially wrote the application, and is now the team lead on another project. Having done (and posted) code reviews on his new project, I can see he's spreading the WTF far and wide.

    Just today, over 20 people are on a conference call since 8AM trying to figure out the daisy chain of dependencies of several projects that need to be deployed. Why? Because his project is AFU because his team forgot to check simple things like: a) do the db tables have the right columns for the release? (some did; he forgot to run some of the scripts) b) is the new data in the tables? (sort of) c) is the new data in the RIGHT tables (no it wasn't), d) do all the pages actually load when you click the links? (no: someone hard coded the url of a development server into something, and so it went.





    Good lord.



    I want to come work with you. I think you make more than me, and I know these people you write about do. I don't think I'd ever have to worry about being fired for being inept like I do now (7 years in, still haven't fired me, guess I'm winning!).



  • @snoofle said:

    Just today, over 20 people are on a conference call since 8AM…

    How much are those 20 people costing the company? Do the shareholders know that this "genius programmer" is costing them that money?

    If I were in this situation I'd be staying silent in the meeting (right now in my life I need the security of a job) but I'd also be looking for an appropriate shareholder representative to anonymously leak this shit to. (No, "passive-aggressive" is not my middle name but it probably should be :-).

    People like this "genius programmer" get away with their crap because no-one ever calls them on it. In my experience the best way to call them on it is financially because its the only thing companies generally care about.

    On the other hand, I enjoy reading these stories so I don't want you to improve your place of work. evil grin



  • @Speakerphone Dude said:

    Hopefully by then you will be on the beach with your wife like that Korean dude who left Enron before the storm.
    Some korean dude took snoofles wife to the beach?



  • @blakeyrat said:

    Look, this is why you bug me: you get into stuff like this and you're perfectly ok with it. Look, if I was in that meeting, I'd take one of two actions: 1) I'd demand the moron wasting hours of everybody's time on a Saturday be fired, or 2) I'd quit. I wouldn't just grin and bear it and go to the same meeting 3 weeks down the road because the actual problems at the company never get fucking fixed and basically that attitude bugs the crap out of me.
     

    In big companies no one cares about such issue especially managemt because they have no clue above "IT is just expensive" while simuntanousley having to deal with a factory outage costing 1 Mio. per day. Meaning it's clear what is more important. So the only option is you leave. But no guarantee your next job will be much better, chances are IMHO bigger it will be even worse.



  • @havokk said:

    If I were in this situation I'd be staying silent in the meeting (right now in my life I need the security of a job) but I'd also be looking for an appropriate shareholder representative to anonymously leak this shit to.

    Why would anyone who is not a competent techie and not familiar with the code believe an anonymous leak instead of "genius programmer"?


  • Discourse touched me in a no-no place

    @Cassidy said:

    groupthink - suddenly we're not alone. We join a crowd (a community, a programming class, a development team) and begin to learn from others, learning from their experiences whilst helping others (and laughing at some WTFs encountered)

    Did you really mean to write groupthink?



  • @PedanticCurmudgeon said:

    Did you really mean to write groupthink?
     

    No. Well, at least not in that meaning of the word.

    I wanted something to imply that it was no longer a sole activity.

    Prizes awarded for an alternative term.



  • @Cassidy said:

    I wanted something to imply that it was no longer a sole activity.
     

    Esprit de corps.

     



  • @Cassidy said:

    I wanted something to imply that it was no longer a sole activity.

     

    Circle jerk?

     



  • @cconroy said:

    Circle jerk?
     

    Oh, yes - love it!

    Wait... hang on a mo.. 


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.