Persistence

"Persistence" is another word for the life span of a piece of data. Persistence takes several forms. Some variables persist

  • for the life of a particular block of code or routine. Variables declared inside a for loop in C++ or Java are examples of this kind of persistence.

  • as long as you allow them to. In Java, variables created with new persist until they are garbage collected. In C++, variables created with new persist until you delete them.

  • for the life of a program. Global variables in most languages fit this description, as do static variables in C++ and Java.

  • forever. These variables might include values that you store in a database between executions of a program. For example, if you have an interactive program in which users can ...

Get Code Complete, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.