Holy bad coding

Discussion in 'OT Technology' started by red, Jun 28, 2007.

  1. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    so I'm digging through some of the code on the project I'm working on, which employs a lot of really big tables of data, and I noticed that, even though each of these data objects specifically has a unique id field, the code which controls which data object to pull when you try to manipulate something in one of the tables ties each unique id to the row's name and stores it in a hashmap and then does a lookup in the hashmap to get the unique id when you try to pull the object. The names are not unique.

    And I'm like.... :ugh:

    ....talk about going out of your way to shoot yourself in the foot. What the fuck was the point of that?
     
  2. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    I dunno what the point is. This is what commenting is for, if only programmers would bother to fucking use it. It's like they think nobody but them will ever read their code! This is why software engineers exist, so there's SOMEBODY to document design decisions and the reasons for making them in a format that people can use for reference twenty years later.

    If the guy who wrote the code is still around, call him and ask him why he did it that way. He might have had a good reason, you never know.
     
  3. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    1. The class isn't doc'd so I don't know who wrote it.

    2. I know why he did it. He needed a way to tie a table row to the right object, and he was too lazy or too stupid to do it right.
     
  4. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Well, just keep a backup of the old code in case some obscure feature breaks when you fix this module. The problem with badly-written code is that it's like a spider web -- you cut one line and half the architecture collapses.
     
  5. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    Yeah. This was also repeated almost 20 times in each instance of a derived class, when it probably could've been built into the base class once. I had to go through and fix all of those instances because I don't have time to redesign the whole fucking thing right now (but it's going in my 'fix this shit' notes for the next iteration).
     
  6. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    sounds like this could have all been done on the database side of things instead of the business object, no?
     
  7. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    I'm talking about UI tables, not db tables
     
  8. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    what language/framework?
     
  9. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    Java, but the framework is Echo2. http://www.nextapp.com/platform/echo2/echo/demo/

    Java code is compile as a war file and hosted on a webserver, which interprets the Java code to spit out an application-like interface in javascript and html. It's 'ajax' on a whole new level. Basically, you're writing a web application as a desktop application.
     
  10. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    :eek3: That's awesome. I might have to look into this. I HATE HATE HATE developing for the web; if this will let me develop a desktop app that just happens to run in a website hosted by a server in god-knows-where, then it might be the silver bullet I've been looking for.
     
  11. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    Have you looked at Ruby-on-Rails? I've been tinkering around with it the last few months, and it's freaking awesome.
     
  12. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    No, I haven't. I'm not a web developer per-se; when I need to do web work, it is 99% of the time tweaks and upgrades to existing material, so I use whatever the existing languages are. Given that the US military has their computers locked the hell down so nothing can be installed on them, that pretty much limits any client-side code to JavaScript.
     
  13. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    You're not writing webapps for SIPRNET sites are you? :mamoru:
     
  14. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    I'm not familiar with that acronym, so I'm guess that means I'm not working on that project.
     
  15. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Noone but the implementing programmer can write comments, and unless he is a software engineer his implementation will suck. This is at the tactical level, not the design level. Designs created up front that ignore the details are useless, and never actually reflect the implementation, because the design iterates as obstacles are encountered.

    More false dichotomy. You SERIOUSLY need to read about something other than Big Design Up Front.
     
  16. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    If you're using a good framework, web development is a joy. Much less overhead than rich-clients. RAILS certainly qualifies.
     
  17. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    You're working on a computer system for the U.S. Military and you don't know what siprnet is?
     
  18. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    I know what NMCI is, do I get any brownie points for that?
     
  19. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Yes, Peyomp. :rolleyes: I'm quite familiar with the concepts of the Spiral Model and the Recursive Waterfall Model. What I said, as opposed to what you inferred, is that the guy who wrote the code should be slapped for not writing any comments in it -- even if only to point out those things that he couldn't get to work correctly -- and other than that it would at least have helped if the design considerations were documented so that the OP would have some idea of whether the coder's kluge was done to achieve some unconventional functionality or whether it was just cheap, fucked up code.
     
  20. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    Spiral Model? Recursive Waterfall? Did you get those from a textbook?

    Dude, keep up with modern software engineering methodologies. Try: Test-Driven Development. Extreme Programming. Agile Development.
     
  21. red

    red New Member

    Joined:
    Jun 30, 2005
    Messages:
    87,095
    Likes Received:
    0
    If I hear the word 'agile' one more time, my ears are going to bleed.
     
  22. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Test-Driven Development? I'll admit you've got me stumped on that one. As for the other two, Extreme Programming and Agile Software Development are both bullshit. Agile Software Development is (to use a simple analogy) like writing a paper and then writing an outline to match after the paper is done -- it always lines up, but you still didn't start out with any kind of infrastructure. Extreme Programming, on the other hand, just discards any kind of planning whatsoever. I have no use for them. Maybe they're useful to you, if you're a code bitch with no balls to tell your boss that the deadline means nothing if the product sucks, but I'd rather get fired for telling my boss to have the foresight to consult with the techs before agreeing to a rushed deadline next time, rather than do a halfassed job. And you know what? Any boss worth working for will get the message; but then, I wouldn't wait until the negotiations are done before offering my expertise.

    - - -

    CLIFFS: Newer != Better. The old methodologies are still around because they still work. We'll see how long "Agile Software Development" and "Extreme Programming" stay popular with project managers that want products that work the first time.
     
    Last edited: Jun 30, 2007

Share This Page