Are We Sacrificing Readability for Conciseness in Modern Java?

saamiabbaskhan

Saami abbas Khan

Posted on September 22, 2024

Are We Sacrificing Readability for Conciseness in Modern Java?

Hey everyone!

I’ve been working with Java’s lambda expressions lately, and something has been bothering me: are we sacrificing readability for the sake of conciseness?

I often see developers cramming everything into a single line, especially when using lambdas, streams, and method references. Sure, it looks clean and concise, but sometimes it’s just too hard to immediately figure out what the code is doing. For example:

names.stream()
    .filter(name -> name.length() > 3)
    .map(name -> new StringBuilder(name).reverse().toString().toUpperCase())
    .distinct()
    .sorted((a, b) -> b.compareTo(a))
    .forEach(name -> System.out.println("Processed: " + name));


Enter fullscreen mode Exit fullscreen mode

I'd love to hear your thoughts!

💖 💪 🙅 🚩
saamiabbaskhan
Saami abbas Khan

Posted on September 22, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related