throw new UserNotLoggedInException();\r
}\r
\r
- List<Trip> tripList = new ArrayList<Trip>();\r
+ // Getting rid of variables in legacy code is great because if we do it,\r
+ // it will be easier for us to refactor the code.\r
+ // Once we take away as many variables as posible we can remake optimizations\r
+ // but not before.\r
+ // We managed to get a symmetrical if (ternary operation)\r
if (user.isFriendsWith(loggedInUser)) {\r
- tripList = tripsBy(user);\r
+ return tripsBy(user);\r
+ } else {\r
+ return new ArrayList<>();\r
}\r
- return tripList;\r
}\r
\r
protected List<Trip> tripsBy(User user) {\r