DEV Community

Discussion on: Write Clean Code Without Loops

Collapse
 
kleinron profile image
Ron Klein

Nice post!
I'm a big fan of clean code myself.
One small comment: I'd use shorter argument names for lambda expressions.
For instance, instead of "employeAndFunday" I'd write "emp" or something similar.
For the ones who already familiar with lambda expressions, I think that the shorter argument name is more readable.
However, it's just a style thingie :)

Collapse
 
moopet profile image
Ben Sinclair • Edited

I wouldn't.

While I agree with the post, I don't think it's easy to read lines with employee2Funday, employeeAndFunday, employee and funday all thrown in across 200 columns of wrapped text.

So I see where you're going. But a variable called "emp" is harder to parse for someone arriving new to the code and doesn't tell you what it is. You might guess it was an "employee" object of some kind. You'd also be worried that other parts of the code would use other abbreviations and searching for words would become a chore.

Naming things is half the battle!

Collapse
 
kleinron profile image
Ron Klein

I see your point, and I'm a huge fan of proper names!

My point is that when I got used to lambda syntax, I found that long argument names somehow stand in the way of understanding the lambda's body itself.

We can agree to disagree about this specific issue...

Cheers!