Skip to main content

28 posts tagged with "Java"

Java programming language

View All Tags

Stop Writing For Loops: Master Java Streams with 5 Essential Patterns

· 14 min read
Mahmut Salman
Software Developer

I used to think Java Streams were confusing magic. I avoided them for months, writing nested for loops like it was 2005. Then I saw a senior developer calculate cart totals in ONE line of code that took me 15 lines. I felt like a caveman discovering fire. 🔥 Let me teach you the 5 patterns that cover 90% of real-world Stream usage—no PhD required.

Mastering Two-Tier Exception Handling in Spring Boot: A Complete Guide

· 11 min read
Mahmut Salman
Software Developer

Ever wondered why sometimes your Spring Boot exceptions are caught by @RestControllerAdvice and other times they're not? Or why your custom AccessDeniedHandler returns 403 before your controller even executes? I spent hours debugging this mystery until I understood Spring Boot's two-tier exception handling architecture. Let me save you the confusion. 🎯

Wait, You're Exposing Your Password?! Understanding Input vs Output DTOs in Spring Boot

· 14 min read
Mahmut Salman
Software Developer

I'll never forget the day I accidentally exposed user passwords in my API responses. I returned the entire User entity from a GET endpoint, thinking "Spring Boot will handle it!" Spoiler alert: It returned EVERYTHING—including hashed passwords, internal IDs, and timestamps. My code reviewer nearly had a heart attack. 😱 That's when I learned about DTOs. Let me save you from this nightmare.

My 'Aha!' Moment: Why Public/Private Actually Matters (And I Was Wrong About Security)

· 14 min read
Mahmut Salman
Software Developer

"Why make something private? Just make everything public. If the coder knows which method to call, they call it. Problem solved, right?" That was me a week ago. I was so wrong. Here's my journey from "public/private is just fancy nonsense" to "holy crap, this actually makes sense!" 🤯

Why Create Custom Exceptions? It's Not Just About the Name!

· 10 min read
Mahmut Salman
Software Developer

"Why create InvalidCredentialsException extending RuntimeException? Isn't it just to get a descriptive name instead of generic RuntimeException?" No! The name is only a small part. The real power is type-safe error handling - allowing Spring to distinguish between different errors and handle them differently without string parsing. Let's see why custom exceptions are essential, not just fancy naming.

Why My Object Changes Don't Stick: In-Memory vs Database Persistence

· 9 min read
Mahmut Salman
Software Developer

"I changed the object's failedLoginAttempts field, but when I query the database again, it's back to the old value! In high school, changing object properties just worked - why do I need to call save() in Spring Boot?" This is the fundamental difference between in-memory objects (what you learned in school) and database-backed objects (what you use in production). Let's understand why object changes don't automatically persist to the database.