Code Review #2: “It ain’t stored until the database says it is”

This was a recent comment on a bug report:

EventImpl stores start and end dates as two strings (milliseconds presentation of date). Not clearly understand how information can be lost.

What is wrong with this statement?

Well nothing is “stored” until there is a persistent representation of the data that will outlast the program being stopped. Period.

Putting some value in an instance’s field does not qualify. Unless and until some storage mechanism (database, serialization to a file, etc.) puts it some place permanent – it is not “stored”.

The developer can only say the value is being stored if:

  1. there is an active transaction;
  2. the object being modified is mapped to the database tables.
  3. the field being modified is mapped to some column within that database
  4. the specific object instance being modified is actually participating in the active transaction. There could be an active transaction that this object is not part of!
  5. the transaction commits without errors

For the particular bug report, neither the field nor the object was persisted by the database. Therefore nothing was stored.

This entry was posted in code review, technical. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *