- #1
- 2,117
- 3,706
I would like to get some ideas for solving problems that occur on large coding projects. I'll just describe one for now but I have plenty of other examples. Please feel free to offer your suggestions, describe problems that you would like to find a solution for or derail it off in another direction. :tongue2:
Some background. I've been working for the past year on a large Java web project that has been under continuous development for over 10 years. The program has seen many developers of various skill levels come and go over the years. Management has been pretty much the same group the entire time and can be set in their ways sometimes. The code is easily in the millions of lines with over 80,000 files in the repository (yes, the term bloatware comes to mind). Obviously, I can't fix everything in the code that has been wrought over the last ten years but perhaps there are ways to gently guide the program in the right direction. I'm not looking to blast how others code - I'm trying to find ways to point them in the right direction. That includes myself if I'm doing something that I shouldn't.
First, an example from the Java If Else Indentation thread. Several developers have their Eclipse IDE set to automatically limit the length of a line to 80 or less characters. When they save the file, it results in deeply nested brackets getting turned into junk like the bolded if statement in the made-up example below:
I wrote the code in the if statement so that it would specifically break weird according to the 80 character limit. Also, the original if statement may not have even started out being too long but grew as various changes or fixes were implemented. The question is, how do you try to guide people away from ingrained coding styles that clearly leave a mess for the next poor guy that has to try to understand it? Meetings? Rants? Bribery?
Some background. I've been working for the past year on a large Java web project that has been under continuous development for over 10 years. The program has seen many developers of various skill levels come and go over the years. Management has been pretty much the same group the entire time and can be set in their ways sometimes. The code is easily in the millions of lines with over 80,000 files in the repository (yes, the term bloatware comes to mind). Obviously, I can't fix everything in the code that has been wrought over the last ten years but perhaps there are ways to gently guide the program in the right direction. I'm not looking to blast how others code - I'm trying to find ways to point them in the right direction. That includes myself if I'm doing something that I shouldn't.
First, an example from the Java If Else Indentation thread. Several developers have their Eclipse IDE set to automatically limit the length of a line to 80 or less characters. When they save the file, it results in deeply nested brackets getting turned into junk like the bolded if statement in the made-up example below:
Code:
private void someRandomMethod(String sql) throws SomeException {
try {
if (someBoolean) {
ResultSet resultSet = null;
Connection connection = null;
Statement statement;
try {
connection = getConnection();
statement = connection.createStatement();
boolean success = statement.execute(sql);
if (success) {
resultSet = statement.getResultSet();
}
else {
throw new Exception("Statement failed to execute.");
}
ResultSetMetaData rsmd = resultSet.getMetaData();
int columnCount = rsmd.getColumnCount();
while (resultSet.next()) {
String data = String.valueOf(resultSet.getString(
"SOME_LONG_TABLE_NAME"));
[B]if ((isOneTypeOfData ||
hasPassedChecksInThisLongMethod(firstVar,
secondVar, "Some random text", data)) && data
!= null && (checkWhatThisMethodSays() ||
checkThisIfTheFirstDidntPass(data)) && (anotherBool
&& todayIsNotTheFirstOfTheMonth)) {
}[/B]
else{
...
}
}
}
catch (Exception e) {
e.printStackTrace();
}
finally {
...
}
}
else {
...
}
}
catch (Exception e) {
e.printStackTrace();
}
}