The Stack Overflow podcast is back! Listen to an interview with our new CEO.
2 deleted 1 character in body
source | link

Others have already made some useful suggestions, let me summarize:

  • 80 characters per line might have been a golden rule in the 80s. Nowadays most people agree that 100 to 130 characters are fine.
  • Use linebreaks inside your expressions.
  • Split lengthy expressions by introducing intermediate results.

I like to add another recommendation: Don't be dogmatic about long names! The larger the scope of a variable is, the more information has to be put into its name. And generally it is a good idea to keepekeep the scope of variables small.

For example, if you have a variable for the column of your keyword encryption table and it is clear that there is only this one table used in the scope of your variable, it is fine to call it column or even col. If the scope is larger and there are multiple tables involved, it makes sense to call it keyWordEncryptionTableColumn.

Another example: If you have a loop with a body spanning two or three lines and have to use an index for accessing elements of an array, there is nothing wrong with calling the index i. In this context it is much more readable (for most people at least) than, say arrayIndexOfMyVerySpecialDataSet.

Others have already made some useful suggestions, let me summarize:

  • 80 characters per line might have been a golden rule in the 80s. Nowadays most people agree that 100 to 130 characters are fine.
  • Use linebreaks inside your expressions.
  • Split lengthy expressions by introducing intermediate results.

I like to add another recommendation: Don't be dogmatic about long names! The larger the scope of a variable is, the more information has to be put into its name. And generally it is a good idea to keepe the scope of variables small.

For example, if you have a variable for the column of your keyword encryption table and it is clear that there is only this one table used in the scope of your variable, it is fine to call it column or even col. If the scope is larger and there are multiple tables involved, it makes sense to call it keyWordEncryptionTableColumn.

Another example: If you have a loop with a body spanning two or three lines and have to use an index for accessing elements of an array, there is nothing wrong with calling the index i. In this context it is much more readable (for most people at least) than, say arrayIndexOfMyVerySpecialDataSet.

Others have already made some useful suggestions, let me summarize:

  • 80 characters per line might have been a golden rule in the 80s. Nowadays most people agree that 100 to 130 characters are fine.
  • Use linebreaks inside your expressions.
  • Split lengthy expressions by introducing intermediate results.

I like to add another recommendation: Don't be dogmatic about long names! The larger the scope of a variable is, the more information has to be put into its name. And generally it is a good idea to keep the scope of variables small.

For example, if you have a variable for the column of your keyword encryption table and it is clear that there is only this one table used in the scope of your variable, it is fine to call it column or even col. If the scope is larger and there are multiple tables involved, it makes sense to call it keyWordEncryptionTableColumn.

Another example: If you have a loop with a body spanning two or three lines and have to use an index for accessing elements of an array, there is nothing wrong with calling the index i. In this context it is much more readable (for most people at least) than, say arrayIndexOfMyVerySpecialDataSet.

1
source | link

Others have already made some useful suggestions, let me summarize:

  • 80 characters per line might have been a golden rule in the 80s. Nowadays most people agree that 100 to 130 characters are fine.
  • Use linebreaks inside your expressions.
  • Split lengthy expressions by introducing intermediate results.

I like to add another recommendation: Don't be dogmatic about long names! The larger the scope of a variable is, the more information has to be put into its name. And generally it is a good idea to keepe the scope of variables small.

For example, if you have a variable for the column of your keyword encryption table and it is clear that there is only this one table used in the scope of your variable, it is fine to call it column or even col. If the scope is larger and there are multiple tables involved, it makes sense to call it keyWordEncryptionTableColumn.

Another example: If you have a loop with a body spanning two or three lines and have to use an index for accessing elements of an array, there is nothing wrong with calling the index i. In this context it is much more readable (for most people at least) than, say arrayIndexOfMyVerySpecialDataSet.