S-TECH Solutions

294 posts

S-TECH Solutions banner
S-TECH Solutions

S-TECH Solutions

@SentinelleTech1

#java and web application developer || We design and develop experiences that make people's lives simply awesome! #ProgrammingIsFun

เข้าร่วม Kasım 2020
49 กำลังติดตาม33 ผู้ติดตาม
S-TECH Solutions
S-TECH Solutions@SentinelleTech1·
"I just need users to go to different pages after login." Famous last words. 3 days of Laravel role-based authentication later: - Middleware not registering - auth() ->user() has no 'isAdmin()' method - 403 errors everywhere #Laravel #WebDev #CodingProblems
English
0
0
0
19
S-TECH Solutions
S-TECH Solutions@SentinelleTech1·
Return Optional and make the intent clear: public Optional<User> findUserById(Long id) { // caller knows it might be empty ✅ } ```
English
0
0
0
9
S-TECH Solutions
S-TECH Solutions@SentinelleTech1·
Bonus: Optional also works great for method returns Instead of returning null and forcing callers to check: public User findUserById(Long id) { // returns null if not found ❌ }
English
1
0
0
9
S-TECH Solutions
S-TECH Solutions@SentinelleTech1·
Java developers: Stop using null checks everywhere. Instead of this: if (user != null && user.getName() != null) { return user.getName(); } return "Unknown"; Use: return Optional.ofNullable(user) .map(User::getName) .orElse("Unknown"); #Java #javadev #CodingTips
English
1
0
0
13