Code Smells
Code Smells
2. Duplicated Code
Location – loadItems() method of ItemList and loadContacts() method of
ContactList. Also, saveItems() method of ItemList and saveContacts()
method of Contact list.
Code smell type – Duplicated Code
Description – Above mentioned methods has simple functionality of
reading file from stream, and appending data to new or existing
filestream. But, same action of reading/writing has been done multiple
times in each method with only difference in Fi
Why this is a problem? – Any changes made to storage later on in project
requires changing code on storage implementation throughout the
project which is time consuming as well as chances are high that certain
places might be missed.
Solution – Making generic storage class that can accept object type and
filename and handle reading/storing data from/to filestream.