# Capstone assignment 2.3
###### tags: `OOP` `Coursera`
<style>
.red {
color: red;
}
</style>
<style>
.blue {
color: blue;
}
</style>
<style>
.green {
color: green;
}
</style>
## Submission
### Code Smell 1: Duplicated code

* Location:
1. loadContacts(Context context) in class ContactList and loadItems(Context context) in class ItemList
2. saveContacts(Context context) in class ContactList and saveItems(Context context) in class ItemList
* Description:
Despite the difference of the name of the function and the class they belong, these two pairs of functions have exactly the same codes. This means that when changes made to any of these functions, the changes will have to be done two times which is error prone.
* Solution: Create a class that handles storage by taking object type and name as its members. It handles reading and storing data.
### Code Smell 2: Use too many Comments
Class EditContactActivity::saveContact(View view)

Class EditItemActivity::toggleSwitch(View view)

* Location:
1. saveContact(View view) in class EditContactActivity
2. toggleSwitch(View view) in class EditItemActivity
* Description:
In these two functions, comments are spread before and over the whole functions. By percisly arrange the name of functions, classes and variables and by using enum and reference nicely, code can be read easily without redundant explaination made by comments. Excessive use of comments can cause extra work if the code changes. Also, outdated comments often occurs and misleads developers.
* Solution:
Make variable name, method name self-explanatory. Use enumerators to define alias.