DEV Community

Discussion on: We should write Java code differently

Collapse
 
philtroy profile image
philtroy

Hi

I'll take a look at PFJ hopefully this week.

With respect to your type inference comment, can you give an example? But I will say in advance that in many cases it makes it a lot easier to read the code when types are automatically inferred.

And my finally (for today at least), code formatting does matter to me. I remember back in 1973 when I was taking an assembler programming course at Penn State University, purposefully not formatting the assembler code well. It was very hard to follow, more so than it would have been just because it was in assembler. And yes, bracket placing is bothersome to me for a few reasons:

  • Many times it introduces a blank line (at the end brace) that distracts from code reabilitiy.
  • Having the braces the way I suggested very clearly delineates visually the block of code (to me at least), regardless of how deep the nesting is.

Thanks for your comments!

Phil

Thread Thread
 
siy profile image
Sergiy Yevtushenko

Here is the detailed explanation with examples: 4comprehension.com/kotlin-type-inf...

And yes, in most cases type inference makes code cleaner without loosing context.

As for formatting. Formatting affects readability, but it should be extremely weird to cause loss of context. And as long as context is preserved, getting used to particular formatting style is just a question of time. Developer may still hate formatting, but once he/she is get used to it, formatting is no longer an issue.