Are you sure that is the alignment you want?



  • I work on a lot of projects that originally started overseas.  Every once in a while you will open a code file and your eyes glaze over.  The longer you stare at it,  the more you start to wonder "Is this code totally convoluted or am I just not smart enough to interpret it?".  Then at some point you run across something that causes an epiphany, and you feel better about your world.

     I spent the morning staring at a class that seemed to have hundreds upon hundreds of lines of unused code, and I was thoroughly befuddled as to why it was written in such a complex fashion.  Then I started running across little gems like this:

            int alignment = 1;

                if (alignment == 1)
                {
                    format.Alignment = StringAlignment.Near;
                }
                else if (alignment == 2)
                {
                    format.Alignment = StringAlignment.Center;
                }
                else
                {
                    format.Alignment = StringAlignment.Far;
                }

                format.LineAlignment = StringAlignment.Center;

     

    And even better yet, the "format" object is not used anyplace in the entire class.  This is one example of many.  So far I have removed over 200 lines of extraneous code (and counting).



  • format.Alignment = Alignment.ChaoticEvil



  • First post score: A



  • @corgimonster said:

    format.Alignment = Alignment.ChaoticEvil
    Applauds Perfect opening comment.

     Anyways...

    One more reason why you should never pay or evaluate someones work just based off of lines of code.



  •  Thanks.

     Based upon the following (just ran across this sitting at the bottom of the class), even the original developers were not confident about the quality of the code.

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

    I agree with them.  Who would ever want to re-use this stuff?



  • What could lead to such large amounts of unused code? You would think that if a function or class is being replaced with another it would make sense to delete the old one. Perhaps the fear of breaking code others have written who may still use it? Or wanting to preserve any undocumented side effects?



  • @Mauszer said:

     Thanks.

     Based upon the following (just ran across this sitting at the bottom of the class), even the original developers were not confident about the quality of the code.

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }

    I agree with them.  Who would ever want to re-use this stuff?

    That's .NET handler code. The server checks IsReusable when it's figuring out caching / object reuse.

    Not to detract from the mess you had in the OP, of course.



  •  I get the impression that the original dev was in way way over his/her head (it isn't exactly junior-level stuff), so he/she found something that was sort of close on the interwebs and fiddled with it endlessly until he/she actually got it to work.  Then he/she just left it there.  It was so unbelievably complex in needless ways that I can only surmise that the original dev didn't really understand it either.



  • This takes me back. My very first job in IT was documenting a freaking Access database for a global clothing manufacturer. This outfit had hired a contractor to create a purchase order system. He created a PO system based on MS Access ... for a GLOBAL clothing manufacturer. WTF? So, I go in there and start documenting. I really didn't understand the thousands of lines of code. I had only been doing this for a couple of years. Yes, My eyes glazed over. Many times. I would literally step through the code trying to figure out WTF it actually did. I found out that a huge amount of it never even fired. Deadwood. I found the insertion point of a particularly large hunk of code and commented it out. Execution never even got there. Huh? Ok, delete the whole damn thing. Something close to 10K LOC gone. The app ran fine. In fact ... better.

     Turns out the contractor had built this grossly over-engineered boilerplate in Access and went around selling it for big bucks all over the place but never provided, or even produced, any documentation or support.

    Ah, the 90's. What a great time to be a geek.



  • @corgimonster said:

    format.Alignment = Alignment.ChaoticEvil

    Personally I'd use Alignment.ChaoticNeutral, but apparently that was deprecated in version 4.



  • But it might be revived in v5, if we ask nicely enough... heck, maybe we could get a three-dimensional alignment chart, with Good/Evil, Law/Chaos, and Commie/Nazi!


Log in to reply
 

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