Code Smells
Code Smells
1. Comment Clutter:
Location: saveContact() method in EditContactActivity class. Problem: Overly
detailed, multi-line comments even for clear code.
Explanation: Excessive comments don't effectively communicate design intent.
They become maintenance burdens, requiring updates with code changes. Outdated
comments can mislead future developers.
Solution: Use self-explanatory variable and method names. Reserve comments for
explaining why a specific approach is chosen, not just what is done.
2. Code Duplication:
Location: loadItems()/loadContacts() and saveItems()/saveContacts()
methods in ItemList and ContactList classes, respectively. Problem: Repetitive
code for reading and writing data to files with the only difference being the file name.
Impact: Changes to storage logic require modifying code throughout the project,
increasing effort and risk of errors.
Solution: Create a generic storage class accepting an object type and filename.
This class would handle file reading and writing functionalities, eliminating
duplication.
Overall:
These suggestions aim to improve code clarity, reduce maintenance effort, and
enhance code reusability.