-
Notifications
You must be signed in to change notification settings - Fork 3
Refactoring
#Step-by-step Re-factoring Problems & Solutions
- Please ensure to run God Class, Long Method, Type Checking and Feature Envy while using JDeodorant.
- [AModel] (#wiki-aModel)
- [AView] (#wiki-aView)
- [BitmapJsonConverter] (#wiki-bitmapJson)
- [BrowseActivity] (#wiki-browse)
- [BrowseView] (#wiki-browseView)
- [Cache] (#wiki-cache)
- [CommentController] (#wiki-commentControl)
- [CommentListModel] (#wiki-commentListModel)
- [CommentManager] (#wiki-commentManager)
- [CommentModel] (#wiki-commentModel)
- [CommentPush] (#wiki-commentPush)
- [CommentSearch] (#wiki-commentSearch)
- [CreateCommentActivity] (#wiki-createComment)
- [EditCommentActivity] (#wiki-editComment)
- [EditMyProfileActivity] (#wiki-editMyProfile)
- [ElasticSearchResponse] (#wiki-elasticSearchResponse)
- [ElasticSearchSearchResponse] (#wiki-elasticSearchSearch)
- [GeoTopicsApplciation] (#wiki-geoTopicsApplication)
- [Hits] (#wiki-hits)
- InspectCommentActivity
- InspectOtherProfilesActivity
- InspectProfileActivity
- [MapsActivity] (#wiki-maps)
- [MyBookmarksActivity] (#wiki-myBookmarks)
- [MyCommentsActivity] (#wiki-myComments)
- [MyFavouritesActivity] (#wiki-myFavourites)
- [ProfilePush] (#wiki-profilePush)
- [ProfileSearch] (#wiki-profileSearch)
- [CacheIO] (#wiki-CacheIO)
- [ReplyLevelActivity] (#wiki-replyLevel)
- [StartActivity] (#wiki-start)
- [TopLevelActivity] (#wiki-topLevel)
- [User] (#wiki-user)
- [UserController] (#wiki-userController)
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- God Class - File + Load - FIXED
Before: JDeodorant recognized that the cache class had too many responsibilities and such it was too large.
Recommended Action: Recommended that we encapsulate the cache IO into it's own class.
Action: Moved the cache IO code using JDeodorant then renamed the class CacheIO to be more in line with its actual duties.
Result: The cache class now handles the internal working of the cache however it does not handle read and write to disk. This is delegated to the CacheIO class now.
- God Class - cache - FIXED
Before: JDeodorant recognized that the cache class had more method's it wanted to extract due to too many responsabilities
Recommended Action: The JDeodorant recommended extractions left the cache class with zero responsibilities so we recommend manually doing a few of the suggested changes but not the rest. Ignoring the rest of the JDeodorantgod class recommendations.
Action: Moved the path variable into the CacheIO class and initialize it through the constructor. Also moved the load method into the CacheIO since it involves direct cache IO.
Result: The cache class now has a smaller amount of responsibilities making it a more concise class.
- Feature Envy - Move Method - FIXED
The above re factoring removed the JDeodorant recommendations for feature envy.
- God Class - new - NOT FIXED
- Long Method - updateComment - NOT FIXED
- Feature Envy - updateComment - NOT FIXED
- Feature Envy - newReply - NOT FIXED
- Feature Envy - newTopLevel - NOT FIXED
- God Class - list - NOT FIXED
- God Class - new + M - NOT FIXED
- God Class - comment + refresh - NOT FIXED
- Feature Envy - refresh - NOT FIXED
- Feature Envy - refreshMyComments - NOT FIXED
- Feature Envy - refreshMyBookmarks - NOT FIXED
- Feature Envy - refreshMyFavourites - NOT FIXED
- Feature Envy - newTopLevel - NOT FIXED
- Feature Envy - newReply - NOT FIXED
- Feature Envy - updateComment - NOT FIXED
- Feature Envy - getComment - NOT FIXED
- God Class - stamp + time + put + M + date - NOT FIXED
- God Class- level + M + es + top - NOT FIXED
- No Bad Smells
- God Class - model + pull + comment - NOT FIXED
- God Class - repli - NOT FIXED
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- God Class - client + profil - NOT FIXED
- God Class - client - NOT FIXED
- No Bad Smells
- No Bad Smells
# InspectOtherProfilesActivity
- Feature Envy - updateUi - NOT FIXED
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- No Bad Smells
- God Class - location - FIXED
Before: JDeodorant recognized that the user class had too many responsibilities and was much too large.
Recommended Action: The JDeodorant recommended extractions were to move the location related code into another class.
Action: Moved the location related code into another class to encapsulate it as UserLocationServices. Also moved any supporting code that was only used by these functions. Had to manually clean up the re factored class as it contained unnecessary code that was never used as well as some poorly named elements.
Result: The user class now delegates its location based functionality to a helper class.
- God Class - file - FIXED
Before: JDeodorant recognized that the cache class handled IO when it could delegate it to another helper class.
Recommended Action: The JDeodorant recommended the extraction of some of the IO in the user class.
Action: Moved the recommented IO plus moved the rest that it did not suggest to move. Re worked the main load/store code for the user in order to allow it to move to another file.
Result: The user class no longer directly handles and of it's disk IO operations it delegates them to the UserIO class. The main user class is now much shorter and has less responsibilities.
- God Class - ID, Favourites, Bookmarks, comments & Profile - IGNORED
Before: JDeodorant determined that the code for handling the users profile ID, list of favourites, list of bookmarks and other profile code should be moved to individual class'
Recommended Action: Recommend not implementing any of these changes. This would involve creating many class files which would make the user class much harder to manage. On top of this the responsibilities of the user class would reduce to meer delegation and we feel that the user class is completly capable of keeping track of its own list of favourites, bookmarks and comments as well as the few fields in its profile.
Action: Did not take any.
Result: The user class remains in controls of its direct fields such as user name, profile picture and its list of favourites.
- Feature Envy - favourite - FIXED
Before: JDeodorant identified feature envy in the favourite method.
Recommended Action: The JDeodorant recommendation was to move this method to the user class.
Action: Moved the method that handled adding or removing favourites into the user class.
Result: The user controller no longer decides if it removes or adds a favourite it simply delegates to the user class which is the rightful place where this decision should be made.
- Feature Envy - bookmark - FIXED
Before: JDeodorant identified feature envy in the bookmark method. This method is handling responsibilities that are not for the controller to handle.
Recommended Action: The JDeodorant recommendation was to move this method to the user class.
Action: Moved the method that handled adding or removing bookmarks into the user class.
Result: The user controller no longer decides if it removes or adds a bookmark it simply delegates to the user class which is the rightful place where this decision should be made.