Singleton without the benefit



  • There are some people who can have all the book knowledge in the world and fail miserably to actually utilize it.  In college, I had plenty of classmates who would ace tests, but when they needed to actually utilize that knowledge, they were more worthless than Vista's UAC.

    Now that I am in the real world (for three years now) those sort of people seem to manage to get jobs.  One of my current co-workers is a textbook example:

    class OrderBusinessLogic* {

        private static final Logger logger = AppLogger.getLogger(OrderBusinessLogic.class.getName());
        private static Collection <OrderData> orderDataCollection;
        public static int tableDataSize;
        public static int orderDataSize = 50;

    /
    using the singleton design pattern idea, return one static class variable
    representing OrderBusinessLogic object to be used through the class OrderServlet
    * @author <<<removed>>>
    * @see orderBusinessLogicFactory
    * @return orderBusinessLogic
    /
    public static OrderBusinessLogic orderBusinessLogicFactory(ApplicationContext springContext, ISiapComponent component){

    OrderBusinessLogic orderLogic = new OrderBusinessLogic(springContext,component);

    logger.debug("orderBusinessLogicFactory()");

    if (orderLogic.orderBusinessLogic == null){
    orderLogic.orderBusinessLogic = orderLogic;
    }
    return orderLogic.orderBusinessLogic;
    }//end orderBusinessLogicFactory

    /

    Using the singleton design pattern idea, if the instance of the object of this class exists already
    * then return it, otherwise, create a new instance and return it
    * @author <<<removed>>>
    * @return orderLogic the current instance of class OrderBusinessLogic
    /
    public static OrderBusinessLogic getInstanceOrderBusinessLogic(ApplicationContext springContext, ISiapComponent component){

    logger.debug("getInstanceOrderBusinessLogic()");
    OrderBusinessLogic orderSeqLogic = OrderBusinessLogic.orderBusinessLogicFactory(springContext,component);
    return orderLogic;
    }// end getInstanceOrderBusinessLogic

    // ...
    // snip
    // ...

    } // end class OrderBusinessLogic

    The actual domain involves the US federal government 

     

    If you ever wanted a singleton, do not want the benefit of singletons and enjoy threading issues, this is how you do it!



  • Here's what you need to do: go to this person's desk and yank their keyboard away from them. To be on the safe side, stomp on their mouse a few times while you're at it.



  •  I especially like that he's using spring and could have just used it to give him a singleton instance when he needs it without adding any more code...



  • @witchdoctor said:

     I especially like that he's using spring and could have just used it to give him a singleton instance when he needs it without adding any more code...

     

     

    LOL, exactly.  I've learned where one WTF resides, more tend to lurk. 



  • @osuwizzard said:

    logger.debug("getInstanceOrderBusinessLogic()");
    @osuwizzard said:
    logger.debug("orderBusinessLogicFactory()");
     

    That's some very impressive logging. The comments are just as useful..

    @osuwizzard said:

    }// end getInstanceOrderBusinessLogic

    I can't believe people get paid to write such crap.



  • @Nandurius said:

    @osuwizzard said:

    }// end getInstanceOrderBusinessLogic

    I can't believe people get paid to write such crap.

     

     

    Since the OP hinted that the application was related to the US Federal Government, perhaps the code author is a frustrated Ada programmer. 



  • @bstorer said:

    Here's what you need to do: go to this person's desk and yank their keyboard away from them. To be on the safe side, stomp on their mouse a few times while you're at it.
     

     Might as well kick him/her in the testicles/ovaries a few times to prevent any unnecessary breeding while you're at it...



  • @livid said:

    @bstorer said:

    Here's what you need to do: go to this person's desk and yank their keyboard away from them. To be on the safe side, stomp on their mouse a few times while you're at it.
     

     Might as well kick him/her in the testicles/ovaries a few times to prevent any unnecessary breeding while you're at it...

    Your ideas intrigue me...



  • @bstorer said:

    Here's what you need to do: go to this person's desk and yank their penis away from them. To be on the safe side, stomp on their nutsack a few times while you're at it.
     

    I'll play madlibs even if I have to make up my own omissions. 

    I've had a fairly uneventful day.

    Can you tell? 


Log in to reply
 

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