Showing posts with label google. Show all posts
Showing posts with label google. Show all posts

Monday, 28 May 2012

Exception Help

Keep find myself searching which exceptions to throw when, in regards to 'this code should never be reached' exceptions. Found a great post by Kevin Bourrillion, a software engineer at Google, which can be found here. Which I've copied below.
"
I've noticed a lot of confusion about what type of unchecked exception is the right one to throw under various circumstances. Here's a very simple explanation of the most common types.

NullPointerException
Multiple schools of thought on this one. Of course, it's thrown automatically by the runtime when you try to dereference null. Many say that you should never rely on this behavior, and should always check for null explicitly. Many also believe that when you find a null reference, you should throw IllegalArgumentException instead of NPE. This way, a thrown NPE always indicates some programming error in the implementation of the method, not a failure of the caller to pass valid parameters. I'm not taking a stand on this issue right now.

IllegalArgumentException
Throwing this exception implies that there exists at least one other value for this parameter that would have caused the check in question to pass. If the caller can't remedy this exception by substituting another value for the argument in question, it's the wrong exception to throw. Note that in some of these cases IndexOutOfBoundsException is more appropriate (and strangely, IOOBE doesn't extend IAE).

IllegalStateException
This exception implies that there are no argument values that could have caused the check to succeed, yet, there does exist at least one alternate state that the instance in question could have been in, which would have passed the check. Note that this type almost never makes sense for a static method, unless you rely heavily on static state (shame on you). Note also that this exception is appropriate whether or not it is possible to actually mutate this aspect of the instance's state, or it's already too late.

UnsupportedOperationException
This means that the method invoked will always fail for an instance of this class (concrete type), regardless of how the instance was constructed.

AssertionError
This is the right exception to use whenever a statement should by rights be impossible to reach.
"

Cheers,
Michael

Saturday, 11 June 2011

Hackers Unite

So, we have all heard about Anonymous; (in)famous for a number of hacks. Well, it seems like they are going to stage a revolution. See the Youtube channel, or the blog for more information. Looks like this is going to be big. 

For those of you with any coding knowledge, go the EnigmaGroup. Test and train your skills. Become the best you can be. Keep information free. Keep in contact. Keep life interesting. Hack the planet. 

If you haven't already, watch Hackers. Above is wallpaper.

When you register, don't forget that Milk referred you. The site has various training missions that simulate hacks. All you get is the site/page to hack and a description of the mission. That's it. The rest you need to figure out on your own.


Protips - Chrome does some weird things when it loads a page that makes the javascript console not get elements from the web document properly. Use Firefox and get FirebugLinux is also pro, but don't bother unless you are getting serious.

I will be posting some information regarding the missions on EnigmaGroup. Don't just go to the forum to find the answers, they aren't there anyway. You need to use the internet. Find the answers. Coding is 10% knowledge and 90% Google.

tl;dr - Safe site that hosts hacking tests and missions for beginners to experts. Now, you want to read it all, huh?

Wednesday, 12 January 2011

QR and Google URL Shortener

Here is the QR code for http://screaminghawk.blogspot.com/. Android has an app that reads these barcodes and then takes you to the sites are adds the contact or whatever the information. Handly dandy ay.
I'm sure you all know TinyURL. Well now google has http://goo.gl/. Because this site is new the URL wills be even shorter. It also tracks page views etc. http://goo.gl/ZafRK = My blog. And then the QR code for that URL is even smaller.
To generate your own QR codes go here http://zxing.appspot.com/generator/. It's fantastico!