Is it looked down upon or bad to write multiple variable declarations on the same line? As in:
boolean playMoreGames = true; int length;
boolean win; int bodyparts;
boolean contains; char blank = '-';
String word; Scanner fileIn;
String guess; Scanner keyboard = new Scanner(System.in);
vs (standard):
boolean playMoreGames = true;
boolean win;
boolean contains;
int length;
int bodyparts;
char blank = '-';
String word;
String guess;
StringBuilder sb_word;
Scanner fileIn;
Scanner keyboard = new Scanner(System.in);
2
I really like the readability of that style, and might use it in a publication, but a good programming style should also be easily editable. It would be very annoying to insert or delete a declaration in the middle of the list, especially if you’re accustomed to being able to do so using your editor’s linewise shortcuts, like vim’s dd.
The other reason people generally stick to one statement per line is that compilers report errors by line number and version control diffs and merges by line. While it’s not that hard to deal with, it makes interacting with your tools that much more convenient.
2
Style is always different everywhere. I’ve never seen this style that I can recall, but that doesn’t matter.
I think it might be seen as pretty strange by many but again, it’s subjective and really doesn’t matter so long as your style doesn’t get in your (or anyone elses) way.
Though I would think this style might get in your way, but if it doesn’t, and you like it, have a ball.
Bad design is looked down upon, style is looked at mostly with curiosity. Though if you’re in a team, style that isn’t uniform with the others is (rightly) looked down upon.
The only other thing to note about style is that while it’s subjective and everyone’s may be different outside of collaborative works, there are often common subsets of style among language communities. While there’s no necessity to follow any of these common styles, there can be benefit in that your code will be easier to digest to more people. As many people are used to seeing style X, if you code in style X, more developers will be able to understand and work with your code if you ever share it.