Dive In: JSnake

Continuing on the Dive In series, we are going one step further and creating a small game using animation: a clone of the classic video game Snake. As always, this will be as small as possible and many many changes can be made (which I’ll once again try to point out). We’ll start from design all the way to implementing and testing it using the easy Water Fall model. You can run the game and download the source code at my JavaCorner.

So, without further ado, let’s start!

Continue reading…

Posted by Panagiotis Peikidis on 25 Mar 2008 - No Comments »

Playing with Try, Catch and Finally

I read a blog post (Greek) recently that described the path Java takes when executing a try, catch, finally block. But before I continue I would like you to consider the following code. What will be printed out?

public class ErrorClass {
    public static void main(String[] args) {
        System.out.println(getMessage());
    }
 
    private static String getMessage() {
        String toReturn = "Initializing";
        try {
            throwException();
            toReturn += "+No Exception";
 
            return toReturn;
        } catch (Exception e) {
            toReturn += "+Catch";
 
            return toReturn +" from Catch";
        } finally {
            toReturn += "+Finally";
 
            return toReturn +" from Finally";
        }
    }
 
    private static String throwException() throws Exception {
        throw new Exception("original exception");
    }
}

a) “Initializing+No Exception”
b) “Initializing+Catch from Catch”
c) “Initializing+Catch+Finally from Catch”
d) “Initializing+Catch+Finally from Finally”

Continue reading…

Posted by Panagiotis Peikidis on 16 Mar 2008 - No Comments »

Social Network for…Babies

Just when you though Web 2.0 social networks could not get any worse, according to Techcrunch’s post on Totspot, a social network for babies has been created! What can someone do? Well, once your baby has finally crawled, you post it! You can also post his first steps, his first solid food, his first dump, anything that you can imagine. And when he is finally old enough to have a mind of his own, he’ll probably slap you in the face for making the whole school mock him for those baby pictures he always wanted to hide.

You know, the funny thing about Web 2.0 and it’s social networks is that people are starting to take them really serious. I have recently read Robert Scoble’s post where he cries about being deleted from Facebook like it’s the end of his life. Relax man, it’s not like being deleted by Facebook makes you disappear from earth or something. It’s a f***g social network like thousands of them out there. And what is that about your privacy? If your videos, photos etc where private you wouldn’t have posted them on Facebook in the first place! That’s not privacy, that’s sharing. Even if they will be deleted some time in the future, you still have them on your computer (except in the case where you thought that Facebook is where you store your files) and could probably post them again and again and again.

Posted by Panagiotis Peikidis on 02 Mar 2008 - No Comments »