This guy is the best!



  • I work with a guy who considers himself a great Java programmer.  I am not sure what he considers great, but his version of great and mine aren't really one and the same.  I just found this gem in some code he checked in.  Why use the enhanced for loop if you just wanted to do it the old fassioned way?

            int i=0;

             for (TreasuryTrade ttrade: list)
            {
                    GenericTreasuryTicketForm genericForm = new GenericTreasuryTicketForm();
                    BeanToForm.translate( list.get(i++), genericForm );
                    formList.add( genericForm );
                }
            }

    Yes, the BeanToForm class is a utility class that converts Hibernate Bean entities into Struts form objects.  I know I know, but there already is a BeanUtils class that does this.  However, this would mean he would have had to name the fields the same in the entity as he did in the form class.  This was too much for him and he opted to do it manually throughout the project.  Yes, everywhere in that class are the getter and setter calls such as: "to.getTradeId(from.getTradeId());". Granted, the previous developer on this project wasn't very good and had set up this structure for the side of the app already in production, but this new functionality was completely seperate and could have been done right, if 5 minutes were taken to set things up.

     

    Ahh the complex life!



  • @amischiefr said:

    Ahh the complex life!
    Yep, thats Java.



  •  BeanToPaula.translate(list.get(brillant++),paula);


Log in to reply
 

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