Funny :-)

I have some too...

btw, this is mine, about 8 years ago, and yes, I don't do things like
that anymore :-)

    protected String encode(String src){
        return 
StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(StringUtils.replace(src,'%',"%25"),'&',"%26"),'#',"%23"),'+',"%2B"),'
',"%20"),'=',"%3D");
    }


following code is not mine (thank g-d) but also ugly:

Random ran;
dbIFC is an instance of a businesslogic unit. Goal is to find a new id
for import of a new company.
while( dbIFC.companyExist(id = (ran == null ? (ran = new
Random(System.currentTimeMillis())).nextInt():ran.nextInt())) );

and that's my favorite comment:
    /**
     * @author xxx - 13.08.2001
     * Transform key figuere value into the value  without exponents
like millon or thousend
     * @param provider provider id that supplies this key figure
     * @param key figure id
     * @prama valau stringrepresantation of key figure value
     * return trafsformated key figure value
     * */

hope you feel better now, as not the only one to deal with boneheaded :-)

Want some more? :-)

here, one junior developer decided that equals isn't cool enough :-)

if(req.getParameter("nMode")!=null){
   try{
    if(req.getParameter("nMode").compareTo("edit")==0){

same guy, same class:
if(myNote.length()>0){
     addBeanToRequest(req,"dohook","true");
    }else addBeanToRequest(req,"dohook","false");

...

how do you check if a String is equal to "true"? Equals is for worms!

return sDo.indexOf("true") >= 0;

....
next one is mine again... I want to clear the cache at 4 o'clock each morning...

private void receiveTimerInvalidateCacheEvent(){
  Date d = Date.currentDate();
  if (d.hour>=4 && d.hour<5){
    //each morning between 4 and 5 am, we will
    //completely clean the cache to enforce mailbox reload and trash cleaning
    log.info("cleaning up the cache.");
    cache.clearCache();         
  }
}

if (d.hour==4) was far to easy :-)

...

regards
Leon


regards
Leon



On 10/31/05, Dave Newton <[EMAIL PROTECTED]> wrote:
> In my quest to make every else feel better about their development
> environments, here is my Beautiful Discovered Code Fragment of the Day.
> Actual code, actual live project, developers unnamed to protect the
> boneheaded.
>
>  From export_generator.jsp (JavaDocs are for the weak), I present the
> following:
>
> <%!
>     public static class Escaper extends FilterWriter {
>         public Escaper(Writer writer) {
>             super(writer);
>         }
>         public void write(char[] cbuf, int off, int len) throws
> IOException {
>             super.write(cbuf, off, len);
>         }
>         public void write(String str, int off, int len) throws IOException {
>             for (int i = off, maxI = off + len; i < maxI; i++) {
>                 this.write(str.charAt(i));
>             }
>         }
>         public void write(int c) throws IOException {
>             if (c > 0x7F) {
>                 super.write(' ');
>             } else if (c == '&') {
>                 super.write('&');
>                 super.write('a');
>                 super.write('m');
>                 super.write('p');
>                 super.write(';');
>             } else {
>                 super.write(c);
>             }
>         }
>     }
>
>     public static final char DOUBLE_QUOTE = '"'; // "
> %>
>
> Thank you. (I left on the dandy DOUBLE_QUOTE definition, complete with
> Java comments (go ahead, I dare ANYBODY to tell me that THAT is a useful
> comment) for your extended plasure.
>
> Dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to