Tobi said:
I'm prepping for the SCJP, and am for the first time playing with
serialization. I was wondering for what cases would serialization be
used, as preferable to storing stuff in a database? I've never seen
it used any place that I have worked. Is it commonly used? Or is it
more common with apps that aren't web based?
Thanks.
Tobi
That depends. Database use can be roughly divided into two categories:
1) Providing structured, secured an (for most practical purposes)
standardized access to structured data.
2) Serializing object values/states with the sole purpose of restoring
them at a later point in time.
Use case 1) is where relational databases where invented for and can by
no means be compared to object serialization in Java. In this situation
the database is one of the core deliverables as well as the integration
point where custom applications and generic analysis and reporting
tools, backup tools etc. can be linked together.
Use case 2) is a heavily stylized way of (mis-) using a relational
database as a storage medium for object states. Numerous ORM tools exist
to help automate this.
To make matters worse people who do not know the difference tend to mix
both use cases inside the same physical database.
Besides a lot of minuses and pluses use case 2) can be similar to object
serialization.
Regards,
Silvio Bierman