To align assignments or not?

If you’ve looked at the code of some well-known maintained C/C++ open source projects, you may have noticed that whenever there are multiple variable assignments they tend to be aligned like this:

first_num      = 1;
second_num     = 2;
third_num      = 3;
fourth_num     = 4;
fifth_num      = 5;
some_other_num = 6;

Enter fullscreen mode Exit fullscreen mode

instead of

first_num = 1;
second_num = 2;
third_num = 3;
fourth_num = 4;
fifth_num = 5;
some_other_num = 6;

Enter fullscreen mode Exit fullscreen mode

This can sometimes also be seen in Makefiles (especially automatically generated ones). But speaking of Java, most IDEs will likely attempt to trim redundant whitespace by default.

So what do you think? Is this style relevant to Java as well?
Also, which one looks more readable to you?

原文链接:To align assignments or not?

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容