Every Day I see code and say WTF.



  • The past year has been quite an experience.  I started doing asp.net back in 2001, then stopped programing alltogether from 2003 to about 1 year ago this month.  A good friend of mine got me a job with him at a small telemarketing company doing asp.net using vb.net.  This is great, I can finally start making some decent money.  The problem is, I'm finally up to speed with things and want to start doing things the "right" way.  Let me explain. (we're also the only two .net developers there.)

    My opinion of the "right" way is to use OPTION EXPLICIT an OPTION STRICT and to use some type of simple naming conventions on variables, not random names.  For the past year, due to the fact that I didn't have the updated knowledge on these topics, I just did it his way and I've noticed a lot of problems with doing it his way.  Let's say I have to go in and work on some of his code, or he asks me to change something for him.  No problem... until I run into statements like this...

    Dim evy = gboffnum( jessica, erik) And the function of gboff num is declared like

    Function gboffnum( jambi, poto )

    WTF is that?  I see jessica and erik delcared at the top of the page as

    Public jessica, erik followed by like 6 or 7 other variables. Then there's good old sqlstr.

    sqlstr is also a public variable. Sometimes it's a sqlcommand, other's its just a string containing a sql query.  This just can't be healthy.  And don't forget about all the late-binding errors I've run across while debugging.

    My friend argues and complains about me trying to get him to use Option Strict (currently I just say Option Explicit to him...  I don't think he's quite ready for an explenation as to what Option Strict is yet nor things like late-binding.)  He says it's just not the way he codes and he likes being able to use one variable for multiple things and that creating multiple variables of correct types just takes up too much memory... WTF. 

    Then there is the program I wrote, which sends data to a webservice.  It takes the webservice anywhere between 3-15 seconds to return a success or failure so I put that into a thread and have the return logged into a database so I can see that everything is working right.  He has told me that by creating this one thread, asp.net actually creates like 200 threads for it because it is called in a server.execute.... WTF.  He's told me code behind is slower and uses up more memory because the page has to call the reference to the code behind or pre-compiled dll.. WTF.   I've been told to only use .htm because it's faster than .html due to the fact that a file with the extension of .html's encoding is different... WTF

    Now, I've gotten him to start giving his variables types, he complains, but he does it.  How do I get someone who is a decent programmer (there is stuff he can do that I cannot) and make him a great programmer?  He's a self-proclaimed narcisist, which is bad because that means, he knows everything, and he's always right (or atleast thinks he's right) and I can almost never win an argument with him when it comes to this stuff, even when I know I'm right and have abundant resources all over the web that tell me I'm doing the right thing.

     



  • I've got a solution for your problem but I'm not sure if the law allows it: a straight punch on the nose for every fscked up line.



  • @Lothy said:

    The past year has been quite an experience.  I started doing asp.net back in 2001, then stopped programing alltogether from 2003 to about 1 year ago this month.  A good friend of mine got me a job with him at a small telemarketing company doing asp.net using vb.net.  This is great, I can finally start making some decent money.  The problem is, I'm finally up to speed with things and want to start doing things the "right" way.  Let me explain. (we're also the only two .net developers there.)

     It's what you deserve for supporting telemarketers. Karma 🙂

    (Usually a projects coding standards clarify things like that. Maybe you should write some and have them signed off 'from above.')
     



  • @Nandurius said:

     It's what you deserve for supporting telemarketers. Karma 🙂

    (Usually a projects coding standards clarify things like that. Maybe you should write some and have them signed off 'from above.')
     

    It's for inbound calls.  We don't call you 😛



  • You need, absolutely need, to buy Resharper. http://www.jetbrains.com/resharper/ It's a heck of a lot faster than the VS2005 refactoring tools.

     Then, go on a renaming marathon. Right-click, rename. Right-click, rename. Commit.

    Oh, and put the ol' submission hold on your friend until he agrees to do things your way.



  • @Lothy said:

    he likes being able to use one variable for multiple things and that creating multiple variables of correct types just takes up too much memory... WTF. 

    I think my eyes are bleeding.

     

    I know what you mean about the identifier names, but you have no room to complain until you've seen files worth of:

    [code]void doProc(param1, param2, param3, param4, param5, param6, param7, param8)[/code]

    [code]void handleMsg(param1, param2, param3, param4, param5, param6, param7, param8)[/code]

    do you have any idea what kind of torture trying to debug functions with all the variables in it "paramX"? 

    I feel your pain though.  I was once told (on a c++ proj I was on) that I should use for-loops over while-loops because they're way faster.  I just nodded my head and used while-loops where I wanted to used whiles and for-loops where I wanted fors. 

    Short answer, if you just started, let him do it his way, but still do what you think is right.  That place is paying you to do the job best you can, so don't compromise. 
     



  • ++c is faster than c++ 😃



  • @webzter said:

    You need, absolutely need, to buy Resharper. http://www.jetbrains.com/resharper/ It's a heck of a lot faster than the VS2005 refactoring tools.

     Then, go on a renaming marathon. Right-click, rename. Right-click, rename. Commit.

    Oh, and put the ol' submission hold on your friend until he agrees to do things your way.

     

    Or you could use Eclipse CDT. 



  • @Lothy said:

    Now, I've gotten him to start giving his variables types, he complains, but he does it.  How do I get someone who is a decent programmer (there is stuff he can do that I cannot) and make him a great programmer?  He's a self-proclaimed narcisist, which is bad because that means, he knows everything, and he's always right (or atleast thinks he's right) and I can almost never win an argument with him when it comes to this stuff, even when I know I'm right and have abundant resources all over the web that tell me I'm doing the right thing.



    He is not a decent programmer. Just because he can get code working that he understands is useless to everyone else. I know several programmers who can write the most impressive crap that works. It's unfathomable, it's unreadable, it's unmaintainable, and I'm impressed - that it works at all. But it works - well sort of. It's not too hard to BS your customers. Get him a copy of Code Complete. Better yet, get yourself a copy because you want to be better coder.

     

    Oh, the fact that he can get badly written code into production is managements fault, ultimately.
     


Log in to reply
 

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