From: Gustavo Martin Morcuende Date: Thu, 24 Nov 2016 23:46:58 +0000 (+0100) Subject: Getting rid of variable makes code easier. X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=a833e15a4989545f4b4909ad780aa5d8eaac8c69;p=JavaForFun Getting rid of variable makes code easier. There could be performance issues, but if there are not problems this code is better. --- 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<>(); }