Showing posts with label exception. Show all posts
Showing posts with label exception. Show all posts

Exceptions

I am nearing the end of the Spring college semester. This semester I am taking a Java programming class. There was one chapter near the end of the course on exceptions. We did not spend much time on it because there is not much time left. However I am still trying hard to wrap my hands around the concept.

Exceptions are not unique to the Java programming language. I know C++ has them. And I would guess many other languages have them as well. It is straight forward how to throw and catch an Exception object. You are just passing a message. However I have still not yet found a great reason to create my own exception classes. I guess I could use them to ensure the caller can separate exceptions with different catch blocks. But aren't they all going to just call getMessage() on my object?

Here is one thing I have determined about exceptions. This also applies to any classes you write. You should not name the class with too long of a name. It gets tiring to type all those characters. Yes I know you can cut and paste. But if there is a misspelling, and there are a million characters in the name, it takes a long time to figure out where I went wrong. I am going to do a bunch of programming projects where I throw and catch exceptions. Perhaps after that I will have a better feel for them.

Screen Output

I am writing a game in Java called dL1. And I need to display a two dimensional grid for the user interface. After Googling the subject, I thought I would try to use the Curses library to do the output. There is a JCurses package for Java which seemed easy.

After I got into JCurses, it took a while to get the test code from the package compiled. However I could never get the test to run without aborting with an exception. I only have 7 days to complete my game for a programming contest. So I decided to roll my own graphics code.

This is a monumental task. However I already have an applet which is displaying some text. Now I need to get my vertical and horizontal positioning down. And I also need to learn how to erase graphics on my screen. But at least I have something to show for it. You can see a screen shot of my first try on my Angband blog page.