One of many objects in Joshua Bloch’s Efficient Java is the notion that lessons ought to permit mutation of cases as little as doable, and ideally under no circumstances.
Oftentimes, the info of an object is endured to a database of some kind. This has led me to eager about the thought of immutability inside a database, particularly for these tables that symbolize a single entity inside a bigger system.
One thing I’ve been experimenting with just lately is the thought of attempting to reduce the updates I do to desk rows representing these objects, and attempting to carry out inserts as a substitute as a lot as I can.
A concrete instance of one thing I used to be experimenting with just lately. If I do know I’d append a document with extra information in a while, I will create one other desk to symbolize that, form of like the next two desk definitions:
create desk myObj (id integer, ...other_data... not null); create desk myObjSuppliment (id integer, myObjId integer, ...more_data... not null);
It’s hopefully apparent that these names aren’t verbatim, however simply to show the thought.
Is that this an affordable strategy to information persistence modeling? Is it value attempting to restrict updates carried out on a desk, particularly for filling in nulls for information that may not exist when the document is initially created? Are there instances when an strategy like this may trigger extreme ache in a while?