Null Java data members versus methods

Software

Classic Java logo

I was working on my latest Java assignment for The Universities with my new Kyou Fujibayashi figure looking on (more on that later) when my seemingly natural instinct to create more work asserted itself. I could have fixed this problem with nulls and moved on, but I decided to create a little experiment.

When programming in object oriented languages I can't ever stand to access data members directly, I always have to use getter and setter methods regardless of how trivial. Problem is, in Java it's not simply a case of declaring data members as private and replacing any direct usage with a getter method later because we're dealing with fundamentally different structures (primitive and not).

For example, in this crappy application we're creating a new NullTest object and directly testing if its nullObject data member is null. Java cheerfully replies with our "We've got a null!" on the console.

public class NullTest {
  Object grilledCheese; // <-- null
  public static void main(String[] args) {
    NullTest x = new NullTest();
    if (x.grilledCheese == null)
      System.out.println("We've got a null!");
  }
}

Peachy. Now what if we try the same thing but we indirectly access the nullObject data member through a simple getter method. Same result?

public class NullTest {
  Object grilledCheese; // <-- null
  public static void main(String[] args) {
    NullTest x = new NullTest();
    if (x.getNullObject().equals(null))
      System.out.println("Getter method null!");
  }
  public Object getNullObject() {
    return nullObject;
  }
}

Nope! If we try running this, we get a big ol' NullPointerException. Our logic on the surface is pretty much the same, but when using objects returned from methods like this we'd have to use a try and catch block. Even better, because we've created a getter method to encapsulate the logic for that particular object anyway, we'd probably do some conditional checks in there instead. I would think.


A particularly ironic error message

Internet

The server at TheOldComputer.com is taking too long to respond

Maybe it's because the computer is too slow and old! HA! ^_^;

Thank you, thank you, you were a terrific audience.


Links for 2009-10-12

Internet

Links shared from del.icio.us today:

(categories: oracle databases sql howto)

(categories: oracle databases sql howto)

(categories: oracle databases sql howto)


iPhoneUserNews and dull comment trolls

Hardware

iPhoneUserNews.com

I'm not just fed up with suspect political lobby groups this evening, I'm also irritated with internet trolls. Firstly to set the scene, I consult iPhoneUserNews.com for my iPhone news (surprising thought it may seem) for six irrefutable reasons that are so irrefutable as to be practically carved into stone. If stone carving could be scripted and delivered through the Internet Tubes. I guess they could be pneumatic. The tubes, not the stone.

  1. Its written by a down to earth, honest person with a sense of humour
  2. See number 1
  3. It is not covered in advertisements or saturated with JavaScript and Flash
  4. See number 1 again
  5. Its not a dispassionate blogging network site with hundreds of interchangeable, generic authors that merely reproduce what we had in the newspaper realm without anything new
  6. Seriously, I mean it, see number 1

Thanks to Neal, I learned about the Blackra1n software and now have a jailbroken iTelephone with 3.1.2, the subject of an up and coming post. Did I say jailbroken, I meant covered in $48 iPod socks.

All this said though, lately he seems to be attracting more of his fair share of comments from people who either don't get his sense of humour, or who merely hurl uncreative four letter insults. Come on folks, if you're going to act all high and mighty by anonymously insulting someone whom you've never met and if you did meet in public you'd probably cower away from, the least you could do is come back with some insults worthy of someone above the age of six. Is that too much to ask?

I remember Jim Kloss from Whole Wheat Radio saying he likes the idea of sites like Tumblr because they don't have comments by default, so you don't have to deal with abuse. For certain blogs I can definitely see where that'd be an advantage — particularly ones of a more intimate or personal nature. For me, the number of valuable comments from nice people far outweigh the negative ones by dull trolls, it's just you have to live with a few of the latter to get more of the former.

I reckon Neal and Joanne O'Carroll should log the IP addresses of the trolls on his iPhoneUserNews site, trace their addresses, greet them at their doors and throw potatoes or kegs full of Guinness or harps at them, or whatever it is Irish people do to get even. As long as he informed me in advance so I could get my jailbroken iPhone 3G to the scene to record the events and put them on YouTube. Not that I'm advocating people jailbreaking their iPhones. Interesting how I came to my own defence regarding jailbreaking hardware devices than physically assaulting people. Well, you know what those moronic advertisements said, you wouldn't steal a car!

On another note, Neal's also great for forgiving me for shamelessly recycling a screenshot from a blog post I wrote back in August.


Revised Aussie coal lobbyist video

Thoughts

Play Spoof of the Australian Coal Association ad campaign

It's never a good idea to be drinking a hot cup of coffee when any kind of paid political message is played on television, but in this case the claims were so outrageous I nearly jumped out of my chair which would have caused the entire contents of the cup to be sent flying all over the computer devices on my table.

If you don't have the stomach for the original advertisement from the Australian Coal Association, they have a handy summary on their YouTube page:

The Australian Coal Industry takes climate change very seriously. Were investing one billion dollars in the development of low emission technologies to reduce green house gas emissions. […]

Fortunately someone else on YouTube going by the apt name of beyondcoal submitted a new version with revised subtitles. For example:

[…] investing less than 5% of revenue over the next decade […]

I'm sceptical of both sets of figures, but it's good to see it doesn't take long for responses like this to come up online, and that there are people willing to think independently of what the lobbyists are saying. Unfortunately there aren't enough of them.


Sudoku for 2009-10-12

Annexe

This originally appeared on the Annexe, back when I recorded daily puzzles.

Sudoku puzzle for 2009-10-12


#Anime Bakemonogatari 12

Anime

If I could come up with a witty opening line to discuss an episode of Bakemonogatari where something advertised didn't happen and instead we were treated to a cute date episode, I'd probably put it here. In lieu of this, the above sentence will have to suffice. Forgive me for sounding distracted, I'm wearing a jumper and it's actually quite warm out today.

Despite being titled Tsubasa Cat and the assumption that it would be about Tsubasa and her catlike oddity, we got a drawn out conversation between Koyomi and Her Senjougharaness, I'm sorry Hitagi. If I refer to her as Her Senjougharaness she may construe that to mean I'm discussing matters with her father in the car. Allegedly she's not a fan of that.

This entire episode could be summarised with one word which looking back now seeing as we're in paragraph three should have been put further up the top somewhere. "Awww." After having a troubled childhood and a father who's always away on business (I would have no idea what that's like -__-) Koyomi has changed her life and her father comments that he hasn't seen her that happy in a long time. Awww.

And what does their date consist of? Lying on a tarp looking up at the stars. Awwww. And how does the date get started? By her awkwardly trying to figure out the words. Awwwww. I can imagine a few people were agitated with the lack of action in this episode, I thought it was cute. Awwwwww. There was even some suggestive talking and some Haruhi inspired ear action. Awwwwwww.

As to the title to which I've already discussed, I genuinely thought at the beginning when Koyomi suggested the day was unforgettable "but…" he was referring to the fact a random person who'd morphed into a cat was going to appear and ruin their evening or something of that nature. No, it turns out this episode was about showing Hitagi in various different up close poses pulling different facial expressions. Like episode 02, I lost count after a few dozen times.

Warning: cheesyness alert. Despite the limited number of scenes and the slower pace, I really did like this episode in an overly cheesy fanboy way! I actually thought the scene with the discussion of Hitagi's dad and Koyomi was sweet, and choosing to go on their first date to a place where her parents used to take her to look at the starts — as cheesy as it sounds — made me smile. I remember my late mum and I going to Ubud in Bali and looking over this particular spot where you could see the terraced rice fields fade off into the distance and in the evening the flikering candlelight in the soapstone carved lanterns down the streets; one of these days I'll take someone dear to me and show them the same things in the same way :).

As for the graphics, they were still excellent even if some of the same stock road footage was used in several dozen places. What struck me was the fact her father's car wasn't one of those retro modern white two door "vehicle" that up until this point were the only ones we'd seen! Even more shocking: I can never spell "vehicle", and both the Mac OS X and Gnome spell checkers can never figure out what I typed! Thank heavens The Googles suggest spelling.

Because of a combination of not having internet for several hundred years, then assignments all being due at the same time, then work piling up (they always come in threes) I had to push this episode discussion whatnot back for several weeks. Bakemonogatari watches saw this ages ago and are probably already watching and discussing the online episodes. Is that a new thing for a production house to do? Haven't heard of anything else being released in this fashion.

Stars are pretty. Singapore banned the night sky with it's luminescent dense city night light glow, particularly ironic given their flag has five stars on it. Adelaide has pretty night skies. I'll stop now.


Another paid post email thing

Internet

Icon by the Tango Desktop Project

This morning I got the following email offering me the opportunity to create paid posts. Aside from the fact I would never agree to do it unless I'd be allowed to explicitly say I was paid to create a post, it looks a tad suspicious to me. Whaddya thing?

Dear Ruben,

As part of expanding our [redacted], we search the net for high quality blogs and gifted web writes. I’ve visited your website and read some of your recent posts, including Back at KLIA at night again, virtually.

Ruben, you definitely have a unique and interesting writing style and an intriguing high quality blog. Since you and your blog meet our quality guidelines, we would like to offer you to join to our unique and highly rewarding program.

About the program – The program links our customers with gifted writers like you and pays them for writing short articles. You already do that, so I’m sure you will be happy to be rewarded for your talent. We do not ask nor expect you to write ads; rather, we give you complete writing freedom and appreciate your creativity and imagination.

I hope you find the concept of our program interesting, and would be happy to provide you more information about it. Please email me back and in the mean time feel free to visit our website [redacted]

If this email does not interest you, I apologize and I will not contact you again.

Sincerely, [redacted]


Sudoku for 2009-10-11

Annexe

This originally appeared on the Annexe, back when I recorded daily puzzles.

Sudoku puzzle for 2009-10-11


Back at KLIA at night again, virtually

Media

KLIA by Julee

While we did live in Singapore most of my life, we did spent a short stint in Kuala Lumpur, Malaysia for my dad's bidness, and I remember all too well when I used to sit at the airport waiting for my sister while I drank coffee at the Délifrance. Julee on Twitter just sent me the photo above a few minutes ago, glad to see its just as I remember it :).

Looking through the super fabulous (ha!) Rubenerd Blog archives, I came across this post from January 2007 called Kuala Lumpur International Airport WiFi is sweet! back when I used to live there. It even had screenshots from my MacBook Pro dual booting Mac OS X and FreeBSD… which I'm still using. How poetic!

Haruhi KDE FreeBSD

So I was at the Kuala Lumpur International Airport (KLIA to people in the know) for a long drawn out reason which I won’t attempt to explain here, and I found myself trying their free WiFi access. Given my experience with TMNet’s WiFi at the Starbucks coffee shops here I was a bit sceptical about how good it was going to be. As it turns out it was faster than out DSL at home!

As you would know if you read this site in any manner resembling regularity I love screenshots, so here are some from my WiFi adventures :D.

klia_wholewheatradio_thumb.png