Persistent storage is vital for modern day computing so that data can be saved and opened in the future.
Persistent storage is vital for modern-day computing
How might data be stored without computers? You may have an address book which stores the details of your friends and family, indexed by the first letter of their surname. Books in a library are organised into categories and then stored in alphabetical order based on the author’s name. As you may already be aware, data also needs to be stored in the computing world. For this, you need the data to demonstrate persistence.
Persistence in computer science is defined as ‘the characteristic of state that outlives the process that created it’. But what does this mean? In some of the previous steps this week you wrote code to write data to external files for future use. The code which wrote these files has since stopped running, but the files that were created still exist — this is persistence. The act of saving and loading files in applications is the most basic example of the concept, but there are other examples. Every time you listen to a piece of digital music, or view a digital photo, you are opening a file that has previously been created and saved.
But why is persistence so important? With persistence the code can save important information to an external file. This could be something as trivial as a high score or as important as patient medical data. Code can also be used to access the data in the file in the future. If persistence did not exist then the code would simply forget and reset each time it is used. Many programming languages have methods and frameworks to save and retrieve data from files. In Python there are the basic file
operations to read and write to files. But these can be developed to work with more complex data structures, just like the address book example above, offering a logical and efficient means to store and access data. For example, you can store address book data in a file using a string, as demonstrated previously, or you could structure the data into a
that uses the name of a person to retrieve their details.
Many beginner programming projects don’t take advantage of data persistence. Where would persistence be useful? In the comments section tell other learners about a time when you delivered an activity which could be adapted to save and retrieve data.