Getting rid of variable makes code easier.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 24 Nov 2016 23:46:58 +0000 (00:46 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 24 Nov 2016 23:46:58 +0000 (00:46 +0100)
There could be performance issues, but if there are not problems this code is better.

TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java

index b2c1650..8061d2f 100644 (file)
@@ -10,12 +10,11 @@ import org.craftedsw.tripservicekata.user.UserSession;
 public class TripService {\r
 \r
        public List<Trip> getTripsByUser(User user) throws UserNotLoggedInException {\r
-               User loggedInUser = getLoggedInUser();\r
-               if (loggedInUser == null) {\r
+               if (getLoggedInUser() == null) {\r
                        throw new UserNotLoggedInException();\r
                }\r
                \r
-               return user.isFriendsWith(loggedInUser)\r
+               return user.isFriendsWith(getLoggedInUser())\r
                                ? tripsBy(user)\r
                            : new ArrayList<>();\r
        }\r