4 ms·
One subtle spacing issue I find quite annoying that I run into a lot is leading tabs before variable names after type definition. IE: int anInt =
by giberson 16y ago
One subtle spacing issue I find quite annoying that I run into a lot is leading tabs before variable names after type definition.
IE:
int anInt = 7;
String aString = "My string value";
ClassName aClass = new ClassName();
In this example it's not the bad because the typedefs are few, trivial and short and there is actually a leader between the words (.). However, in real code where you have longer class names used in tandem with standard types like int or String as well has some times a dozen definitions--suddenly you wish you had a ruler you can put on the screen.
int anInt = 7;
Service_Ups Svc = new Service_Ups();
ClassNamesCanGetLong variableNamesToo = new ClassNamesCanGetLong();
- isleyaardvark 16y agoIt doesn't make a lot of sense to put tabs between the variable and its value. Between the type and the variable name makes sense because how often do you try and look something up by type versus by variable name. But when you're looking for a particular variable, you tend to want to see its value right away.
- joe_the_user 16y agoAny kind of fancy formatting is bad because it takes effort to keep it maintained and so it creates a reluctance to change that code. It also creates an illusion of correctness through looking good.
- jacquesm 16y agoThere are situations where it really helps though. If you have a series of operations that are unique enough not to be handled by a loop but that change in subtle ways making the changes stand out is an easy way to verify that you're doing it right.
- pushtheenvelope 16y agoPersonally, I much prefer this way. I never noticed it on smaller projects but now I have to work on a large codebase where some functions become hundreds of lines long. Having variable declarations and assignments structured this way makes it much easier to parse while scanning the code.