From a833e15a4989545f4b4909ad780aa5d8eaac8c69 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Fri, 25 Nov 2016 00:46:58 +0100 Subject: [PATCH] Getting rid of variable makes code easier. There could be performance issues, but if there are not problems this code is better. --- .../main/java/org/craftedsw/tripservicekata/trip/TripService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java b/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java index b2c1650..8061d2f 100644 --- a/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java +++ b/TDD/src/main/java/org/craftedsw/tripservicekata/trip/TripService.java @@ -10,12 +10,11 @@ import org.craftedsw.tripservicekata.user.UserSession; public class TripService { public List getTripsByUser(User user) throws UserNotLoggedInException { - User loggedInUser = getLoggedInUser(); - if (loggedInUser == null) { + if (getLoggedInUser() == null) { throw new UserNotLoggedInException(); } - return user.isFriendsWith(loggedInUser) + return user.isFriendsWith(getLoggedInUser()) ? tripsBy(user) : new ArrayList<>(); } -- 2.1.4