User loggedUser = getLoggedInUser();\r
boolean isFriend = false;\r
if (loggedUser != null) {\r
+ // Feature envy. TripService envies User class. This should be done by User class.\r
for (User friend : user.getFriends()) {\r
if (friend.equals(loggedUser)) {\r
isFriend = true;\r
break;\r
}\r
}\r
+ // The deepest branch. For refactoring legacy code we must begin from the\r
+ // deepest branch. This is just the opposite for creating the unit test\r
+ // for our legacy code.\r
+ // 1. Write the unit test from the shortest to deepest branch. Modifications\r
+ // in legacy code must be done JUST with the automatic tools provided by the IDE.\r
+ // 2. Once the legacy code is under test start refactoring from deepest\r
+ // to shortest branch. Modifications in the legacy code may be hand made.\r
+ // In this case we can not do anything with this code (this is the deepest branch)\r
+ // so we will have to start with the for loop (which is the second deepest branch)\r
if (isFriend) {\r
tripList = tripsBy(user);\r
}\r