Simon Wistow (deflatermouse) wrote,
Simon Wistow
deflatermouse

I work in a factory, don't wanna be late

I've been doing a lot of Java recently. Once, long ago, I used to do Java as my day job and always found it oddly constrictive. In the intervening half decade plus my contamination^W exposure to scripting languages has only deepened so this time around the constrictiveness has been upgraded from "Like an overly tight pair of jeans" to "Like having my balls crushed in a vice".

Part of the reason is, I think, the strange and almost religious reverence of Factory classes. I often joke with my flatmate, a paid up member of the Cult of Java, that in most sane languages you can increment doing any of the following

     i++;
     i+=1;
     i=i+1;


in Java it's more likely to be

    Integer            i                  = new Integer(1);
    IncrementerFactory incrementerFactory = IncrementerFactory.getInstance();
    Incrementer        inCremenTer        = incrementerFactory.getIncrementer();
    incrementer.execute(i);


Oh how we live the rock'n'roll lifestyle, sitting round the fire, swapping programming jokes.

I understand the point of factories, especially since, I'm lead to belive, you can build apps using Beans etc etc that will automagically scale from one machine to a massive, n-way failover clustered farm, but sometimes it may go a little far.

Yesterday I was attempting to get rid of all warnings from my Java app because the little yellow exclamation marks! in Eclipse have the same effect on me as an single upside down book in a bookcase does on an OCD sufferer. I put this down to my years working at the big Y! or possibly too much time playing Metal Gear Solid (most. overrated. game. ever[*]). I finally get down to my last set.

I had been doing

    Date date = new Date()
    System.out.println(1900+date.getYear());
    System.out.println(date.getMonth());
    System.out.println(date.getDate());


but those methods are now deprecated so instead I have to do ..

    Date date = new Date();
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    System.out.println(cal.get(Calendar.YEAR));
    System.out.println(cal.get(Calendar.MONTH));
    System.out.println(cal.get(Calendar.DAY_OF_MONTH));


which for reasons I can't quite vocalise, offends me at a nigh-spiritual level.

Ah well, back to tracking down synchronisation bugs that peg my CPU at 100% and render my machine unusuable for 20 minutes.

Bonus points to the person who can tell me which song the subject of this post comes from.

[*] Apart from possibly God of War
Tags: factories, java, patterns
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 10 comments