The wonders of JAXB

I never enjoyed XML.

There is nothing in it that would make like more of XML to store settings than for example an old fashioned INI file. It is simple, anyone can read and edit.

They say XML is readable and editable with a text editor, I don't share the same thought. I've used XML across the years for a myriad of stuff but the fashion never got to my taste nor convinced me much - until today.

I had a problem. Wanted to save objects from a running program onto the disk. I don't want to use Hibernate nor go into the trouble of setting up a database. I want something simple, something that I can just code in a few lines and keep performance at best peaks.

And here we go: Try JAXB using this example ->

It is simple. When I mean simple, I mean as simple as creating a class, adding up the setters and getters for the variables that you want store and add one annotation. After this, two or three more lines wherever you want to make use of this information: brilliant!

Works great, works fast. I'm still a die-hard fan of INI style files to keep settings but I now use XML to store complex objects in a simple fashion.

Great stuff.

No comments:

Post a Comment