Custom Java exceptions

Software

Well today in Java we learnt how to throw our own exceptions. Because Exception is an inherited object of Throwable rather than just a primitive or a pointer we can create our own Exception objects for circumstances where we want Java to treat an event in the same way as an error.

public class TrekError extends Throwable {
  public TrekError() {
    // pass to superclass (Throwable) constructor
    super("Your logic is fatally flawed!");
  }
}
public class TestTrekError {
  public static void main(String[] args) throws TrekError {
    boolean trekBetterThanWars = true;
    if (trekBetterThanWars == false) {
      throw new TrekError();
    } else {
      System.out.println("Live long and prosper!");
    }
  }
}

As I think back to programs I've written in the past in other languages this could have been quite useful! Do Ruby and Python offer similar capability?

The main question I had that I didn't have time to ask in the lecture though was what the "better" or more correct way to use this in Java is. Are there circumstances where you could use such a technique but it would be a cheap shortcut rather than writing robust code? I suspect for all the usefullness that could be derived from this, it could also be easily abused.


Rubenerd Fun Fact #77: Shane Rogers

Thoughts

Kenny Rogers over Shane Warne

Here's another Rubenerd Fun Fact for all you rabid Official Rubenerd Fun Fact fans. I know you're out there, I can hear you breathing. Oh wait, that's me.

Placing a photo of Kenny Rogers over Shane Warne’s head on a live TV stream does not make Shane Warne Kenny Rogers.

Thank you.


#Anime Bakemonogatari 04

Anime

Well after the token effort by Koyomi to help Mayoi in episode three of Bakemonogatari we finally spend some time with them all walking around the neighbourhood looking for what we later find out is Mayoi's mum's house. I'd forgotten for the first few minutes that this was a part two and didn't understand the significance until I remembered it was Mothers Day. I'm not slow I'm just… wait, did you just call me… slow?

Despite HRH Hitagi allegedly only leaving the neighbourhood a year ago, due to that pain in the arse known as urban renewal the trio are constantly overshooting where they're supposed to be going. And I thought she was supposed to be a genius; well I guess she said it herself that intelligence is a relative thing isn't it?

Anyway despite an exhaustive search with some killer backdrops that alas become a bit tiresome after seeing them several dozen times and despite her calling on Epic Hawaiian Shirt Guy and despite using her mobile phone GPS whatsit they never do find Mayoi's mum's house and the return to that gigantic playground. I think that was it. Wait, did you just call me slow?

I was hoping I wouldn't ever say this about Bakemonogatari, but this was the first episode I saw that I wasn't terribly fussed about. When I first started watching I was blown away by the production quality and the awesome characters, but even Hitagi's witty, deadpan-delivered lines that I admit to loving perhaps a little bit too much couldn't save this otherwise relatively lifeless outing.

As I said in my previous review, often I revel in trivial, silly episodes where very little happens; I made reference to the infamous episode where the story revolves just around Kyon collecting a room heater as being one of my favourites of the series. For this episode though, not so much. Perhaps this series set my expectations a little too high so when it came up with something more mediocre it had much further to fall, if that makes sense. Ah well, here's looking forward to episode 5.

Oh one thing I did forget, this huge playground park thingy did lend itself further to some extremely convenient character placement; for the first time since episode one (nowhere near enough, I might add) we see the Class President to End All Class Presidents again, though after seeing Mayoi's and Koyomi's confrontation all she did was bend down and pat her on the head! Ah the impracticality of it all ^_^.


Westpac’s bold new advertising campaign

Thoughts

Photo is of the ANZ and Westpac bank buildings on an appropriately drizzly day in central Adelaide, by Dodge 76 on Flickr.

Photo is of the ANZ and Westpac bank buildings on an appropriately drizzly day in central Adelaide, by Dodge 76 on Flickr.

I saw Westpac's latest television advertisement on the television. Which was a good thing because I spent weeks looking at a banana expecting to see a Westpac television advertisement but all I got was banana. It did start changing from yellow to brown though in it's fourth episode, but by then I'd lost interest due to obvious scripting problems.

The new slogan Westpac was proudly trumpeting on television:

We’re a bank you can bank on.

Need to read that again?

We’re a grilled cheese sandwich you can bank on.

Don't believe me? After doing a bit of digging online to determine whether or not I had in fact heard what the advertisement was saying correctly, it turns out they're so proud of it you can download it from their website!

Now ladies and gentleman having just seen said advertisment, I have so many words and thoughts spinning through my head as we speak that I don't quite know in what order to type them here if at all. Perhaps starting from the beginning would be a useful thing to do.

Firstly, I know what you're thinking. I'm not psychic, I'm just very good at reading people. The Westpac Bank advertising itself by saying that line is silly because we ALL KNOW this line was already used in a BusinessWeek article from 1992 about the Chicago Bank. I checked Wolfram Alpha, and this is the difference between Adelaide where Westpac aired this advertisement, and Chicago where I've divined the Chicago Bank has its headquarters:

Adelaide and Chicago distance

The second, perhaps more subtle aspect of this advertising campaign which you probably haven't figured out for yourself is just how needlessly unnecessary it is. Yes Westpac you're a bank, and if I do business with you I know I can bank with you. This I can figure out from the fact you're a bank, I don't need restaurants telling me I can eat their food, or the vending machines at the Mawson Lakes campus of my university telling me they'll take my change and give me nothing in return. This is to be expected. You're not crediting (HA!) your audience with much intelligence.

Perhaps the problem is Westpac is being direct and forthcoming, but they're not quite at the point where Captain Obvious swoops down from the sky to proclaim he's Captain Obvious. I suggest this slogan with a very clever pun for their next campaign.

We’ll keep your money safe, as well as in a safe.

I wonder how much Westpac paid their advertising agency for their current slogan, and whether they're kicking themselves now that they know they could have just come to Rubenerd.com and got one of equal calibre for free.

2019 Update: Fixed the broken image.


Australian Central Credit Union, PermitCookies

Internet

That mouth on their site has always scared the crap of me!

As I've said here in the past, the primary reason why I use Firefox isn't for the superior browsing experience any more but rather for the security and privacy extensions, though sometimes they do break some sites.

In the case of the Australian Central Credit Union online banking site (try saying that three times in a row really fast!), simply enabling cookies and scripting with PermitCookies and NoScript on the accu.com.au address still generates "you need to enable cookies in your browser" errors, and if you get past them you then can't enter in your unique personal icons combination because they don't appear!

As with some other sites that uses frames, the problem is the ACCU frame is hosted on their primary domain, but one of the pages in the frame references an external site which means your whitelists don't include it.

The solution:

  1. Right click (CTRL-Click on Mac) on the error page
  2. Choose This Frame > Open Frame in New Tab
  3. In the new tab, enable cookies and JavaScript with PermitCookies and NoScript
  4. Close that tab, return to the ACCU site

I've been told by more than a few people on Twitter that I'm paranoid by going to these lengths to block cookies and scripting, but to be blunt we are talking about dealing with bank accounts online and I'd rather be safe[er] than sorry. And besides, once you've set it up once, you're good to go each time you visit. For me, the minor initial inconvenience is offset by the security and privacy of only having cookies and scripting I explicitly authorise running on my machine.

Now if you'd excuse me, my tin foil hat fell off and I ran over it with my computer chair. Might need to make a new one.


Singapore doesn’t get much cartographic luck

Media

MediaWatch screenshot

I remember back when MediaWatch here in Australia busted several television news programmes for putting Singapore at the end of Sumatra on their maps instead of on the end of Peninsula Malaysia. An honest mistake I guess, the entire island of Singapore is smaller than metro Adelaide but I worred that nobody noticed or picked it up!

From their 28th of October 2008 episode which you can download the video of and watch:

ABC News relocates Singapore to a spot between Java and Sumatra, in the heart of Indonesia. And nobody spotted it. The dodgy map was used in ABC bulletins all over the country for the next 24 hours.

Anyway it seems perhaps news programmes can be forgiven for thinking Singapore is somewhere else because even some of ASEAN's official documentation puts Singapore on an island in Indonesia, and as with the original ABC Australia story above, other news agencies have picked up the map too without checking it. Aiyo.

For the sake of comparison, here's the map of Singapore from Wikipedia:


#Anime Know your Senjougahara Hitagi moods II

Anime

Absolutely insane
"Absolutely insane"

You may recall last week I reviewed the third episode of Bakemonogatari and that I made the comment that Hitagi got so many head shots that I lost count after 14. Well I had a brilliant idea to use all those superflous eye frames (didn't realise that was kind of a pun until after I wrote it) to make an entire long-winded series about being able to tell Hitagi moods, but today I had a sudden onset of "better judgement" and decided this will be the last one.

I know, I know, I can already tell you're disappointed and upset beyond belief, but I'm sure you'll be able to survive. It wasn't you, really, it was me.

As I said in part one of know your Senjougahara Hitagi moods, this post is purely for educational purposes only, I will not be held responsible if you find yourself with a stapler in your mouth. Thank you.

Fanciful
"Fanciful"

Mad
"Mad"

Apprehensive
"Apprehensive"

Cheeky
"Cheeky"


Facebook buying Friendfeed, off to Tumblr

Internet

FriendFeed

A lot can happen when you're asleep! If you're on Twitter this is already ancient history because it happened hours ago, but Facebook came completely out of left field and bought FriendFeed. I agree with what Dave Winer said about it, that the deal can only be bad news for current FriendFeed users.

To use the technical social science language I have acquired from being a super 1337 online citizen for a while now, I have a Facebook account but they still kinda creep me out and this deal rubs me the wrong way. I hate the idea of general purpose gated communities where you have to log in to access material, and while there's no evidence Facebook will simply swallow FriendFeed into people's profile page news feeds to be never seen on the public internet again, it is a possibility. Even if they don't do that, I'm sure we can look forward to some new archaic and scary terms of service.

While I had most of the feeds for my online activities connected to it, I never really used FriendFeed itself for anything except for one time quite recently. I'm thinking I'll move all my feeds onto my neglected Tumblr account and ditch FriendFeed.

One of the people commenting on the FriendFeed blog about the decision said part of the reason he liked FriendFeed was that it was a social network that wasn't Facebook! Oh well, back to Twitter for short messages which fortunately was spared.

Such rich world problems we worry ourselves with.


The Mauretania in 1906 and whatnot

Thoughts

Back when I was in high school one of my obsessions was the early 20th century; not really World War I or II but the history, music, architecture, design and art in very few places other than the magnificent ocean liners could you find all of it at the same time! Well maybe the Chrysler Building ;).

This was post 1906 which I remember as the year when the RMS Mauretania was launched. From memory at the time (what I used to read, I'm not implying I was there!) Cunard had appealed to the British government for a loan to build two new superliners in response to Germany's eclipsing of the UK as the dominant transatlantic passenger carrying nation.

From my biased perspective as a tech guy, what was more significant though was their propulsion systems. The Lusitania and Mauretania were the first full sized ships to use steam turbines instead of reciprocating engines which at the time was a huge gamble, but one which ultimately paid off; the turbines were lighter, smaller and faster and allowed each to win the Blue Riband transatlantic crossing record. The Olympic and Titanic which were built later were larger, but in many ways were inferior with older style engines and rudders.

The Lusitania served as a transatlantic liner until World War I broke out and she was sunk by a torpedo while acting as a hospital ship. The Mauretania served as a troop ship in World War I and as a passenger liner until she was withdrawn from service in 1934 and scrapped in 1935. Okay I cheated and looked up those years.


Java multiple interface ambiguity

Software

I've been told in lectures that the reason why Java doesn't support multiple inheritance is because every class inherits from the Object class which negates the need for it (perhaps), and because it prevents problems encountered in languages like C++ where multiple parent classes might have methods and data members with the same signatures and names.

What Java does support though is multiple interfaces which lends objects consistent behaviour even if they're completely different:

public class Bicycle implements PeddlePower, Purchasable {
   // I want to ride my bicycle,
   // I want to ride my bike…
}
public class Keyboard implements Purchasable {
   // Bucking spring keyboards are the shiz
}

What I wanted to know is whether or not different interfaces with the same abstract methods and data members could cause a similar clash to the ones avoided by not having multiple inheritance, or whether it would cause an override.

public interface InterfaceA { final int x = 4; }
public interface InterfaceB { final int x = 4; }
public class Testing implements InterfaceA, InterfaceB {
   public class Testing {
      System.out.println(x);
   }
}

Turns out it does generate an error, and now that I've seen it, it does make sense.

Testing.java:5: reference to x is ambiguous, 
both variable x in A and variable x in B match

My reasoning was: imagine you're passing the Testing object to a setter method that accepts any object that implements InterfaceA. I assumed it would know to use the int x data member from InterfaceA and NOT from InterfaceB right? Well of course not, just because it's been passed through something that only accepts objects that implement InterfaceA, that doesn't mean it's lost it's InterfaceB!

Anyway to seasoned Java folk this probably all seems childish and silly, but I find if I try to explain a logic problem out loud to somebody, often I learn the answer myself in the process; in this case why two interfaces can't have methods and data members with the same signatures and names after all! Well technically they could provided you're sure both interfaces will never be used on the same objects at the same time.