1.4-Software-Development-Principles

Using Java records for conversion

Reading data with records

Once again you are presented with several data files. You may recognise them:

Your assignment is to choose one of these files (or all of them) and read them using a record class. You are specifically not allowed to use a class that you designed.

Save to the other format

If you chose one of the csv files then your assignment is to export the data to a json file. Inversely, if you chose a json file, then your assignment is to export the data to a csv file.

Further steps

Upon reading data, make the user choose the format (and the filename) to which to save the data. Create a generic interface so that the program doesn’t need to know what the save file format is going to be.

Can you make it so that by choosing the file, the system automatically knows the record type and the implementation that can read such a file to a list of those records?

Conclusion

The point of this exercise is to concentrate on reading and saving data. The actual memory model for that data is always simply a record. This may change the way you would normally read and write a csv file, and in certainly will influence how you read a json file.

You may notice limitations of using records. That gives you a clearer understanding on when to use that technology.