Archive for September, 2004

Java.net: Java Tech: The ABCs of Synchronization

“Correctly synchronizing threads is one of the more challenging thread-related skills for Java developers to master. This article begins a two-part series that attempts to meet that challenge by exploring the fundamentals of Java’s synchronization capabilities. It begins by introducing you to the concepts of monitors and locks. You next will learn how synchronized methods and synchronized statements implement those concepts at the language level. Finally, you will learn about deadlock, a nasty problem that often occurs when synchronizing threads.”

Haven’t read it yet, but it looks interesting. I really just posted it here as a reminder to myself to read the article.

Java Tech: The ABCs of Synchronization, Part 1
Java Tech: The ABCs of Synchronization, Part 2

Changing a class kills serialization

Here is the setup for something that I learnt today about Java. The app that I am working on uses serialized objects for part of the testing phase. However, today, the Class that these objects were based on was changed; two methods were added to the class. This resulted in the deserialization code throwing an Exception (I can’t remember which one).

The point of this is that if you serialize an object and then change the class that object is based on, the serialized object is useless. You can not deserialize it into the modified class.

If you are trying to hack together an application like we are, this is something to keep in mind. The change to the class was fairly minor, it resulted in two methods being added, but it still had some fairly major side affects.

I got rhythm, I got gmail, anyone want to ask for anything more?

It seems that I can not get rid of my gmail invites fast enough these days. So, I have 5 of them to give away. They are free to a good home. Since I started this post off by murdering a song, I should make everyone work the gmail into the lyrics of a song, similar to the title above. The ones that I like, will get gmail accounts.

Uploaded new version of code base

In an act of good will, and because someone said the old files didn’t work, I have uploaded the current version of the fuzzylizard CMS that powers this here website. You can find it for download under the CMS Download link.

As always, these files are provided as is with no guarantee, warranty, or anything else resembly any thing similar to a warranty, yada yada yada. So if you unzip these files onto your computer and they destroy every file on your computer, set fire to you drapes, burn your supper, and get you fired from your job, it ain’t my fault.

The files have been run through a virus checker though. Have a nice day. :-)

Opinions on Logging

In my code, I tend to do a lot of logging. Especially now that I have discovered Log4j. This allows me to log my statements to a text file instead of printing them all out to the console. Which may or may not be an option depending on the application.

Scott Ellsworth has written a blog article detailing reasons why he feels that logging can be a very usefull tool for debugging code. He also offers up several guidelines for the proper use of logging statements. According to his guidelines, I definitely use way too many logging statements. On the other hand, I am still learning and I am sure as I gain more experience this will decrease. Anyway, check out the article, it is an excellent read for any Java programmer.http://weblogs.java.net/pub/wlg/1886

Java Discovery: String.split

In my first year at Ryerson I had to do a java programming assignment where the point was to take a fairly long string, tokenize it, and then do something with each of the words (I can’t remember what we had to do). The real point of the exercise was to get us used to reading input from the command line and using the String Tokenizer.

Today, I had to create a class that split a string a comma separated string. This is very similar to the assingment describe above. So I went to the javadoc for StringTokenizer and read that it was deprecated and the you should use the split method in the String class.

So I went over to the javadoc for the String class. Sure enough, there is a beautiful little method called split. What split does is it splits a string using whatever token you pass it as the delimiter and returns an array of Strings.

Personally, I think this is pretty cool. I have got to read through the javadocs more often and find out what all is hidden within the Java language.

Article Link

What am I working on?

This is a topic that up till now I have not really written much about. I am hoping that this will change. Therefore, currently I am working on a simple Flash remoting app that will allow a user, in this case my wife, to create invoices for her photography clients. The front end will be done in Flash with the backend done in Java. The database will be my new favorite DBMS PostgreSQL.

The main point of creating this program is as a starter app into Flash Remoting and Java. As such, the backend will use plain old java objects instead of session beans. As I refine it further I may eventually make the move to a more J2EE centred design.

So far I have the data model worked out and the tables setup in PostgreSQL. I also have a small amount of the Java code worked out. In addition, I also have a little of the interface designed. This I am doing directly in Flash as it seems to be faster for this project. Although, this is proving to be a bit of a problem as I seem keep hitting walls where ever I am uncertain of the implementation. I guess every project has its problems. For this one, it is the interface.

As I progress with it, I will post more information on the project and some of the things that I have learned doing it. Stay tuned.

Next Page »