Competition

by Bjørn Storkholm 28. June 2009 17:30

Who can show the worst code ? Recently I ran into something like this:

        public string[] GetSomeVeryStupidArray()
        {   
            Dictionary<string, string> customers = GetCustomers();
            string[] list = new string[customers.Count];
           
            list[0] = customers[Constants.FirstConstant];
            list[1] = customers[Constants.SecondConstant];
            list[2] = customers[Constants.ThirdConstant];
           
            return list;
        }

        private Dictionary<string, string> GetCustomers()
        {
            string[] customers = new string[]
            {
                Constants.FirstConstant,
                Constants.SecondConstant,
                Constants.ThirdConstant
            };

            Dictionary<string, string> values = new Dictionary<string, string>();
           
            foreach (string name in customers)
            {
                values.Add(name, name);
            }

            return values;
        }

        internal class Constants
        {
            internal const string FirstConstant = "FirstConstant";
            internal const string SecondConstant = "SecondConstant";
            internal const string ThirdConstant = "ThirdConstant";
        }

Obviously I rewrote this a bit, so I don't offend the person who accually wrote it, but what the f*** is going on ??? I found code similiar to this, in accual production code. The worst part is, that I saw, that some other developer has been copy pasting these methods into new areas of the application we're working on, without even thinking about, what it is he's pasting.... Only two days left...

Add comment



biuquote
Loading



Powered by McDonalds

About Bjørn

Bjørn StorkholmBjørn Storkholm has been working in the IT industry since the mid 90es, with a primary focus on Microsoft technologies. Started developing on the dotNet platform in 2001, when it was in it's early beta stages.

About the blog

This is a place where I can discover my own findings, after they have slipped my memory. But maybe others can find some usefull stuff here as well.

The blog is powered by BlogEngine