I'm curious about this. I've recently had the idea of isolating segments of code using the curly braces for both visual organization and to isolate the variables to that specific scope (if only to keep them from cluttering the suggestions in Eclipse in larger functions). For instance:
public void startInstall()
{
boolean success = false;
m_progress = 0;
// Determine Chance of Success (This is isolated in curly braces)
{
double weight_total = 0;
double weight_sum = 0;
for(int i=0; i < Data.m_feature_selection.size(); i++)
{
if(Data.m_feature_selection.get(i))
{
int weight = Data.m_feature_weight.get(i);
weight_total += Math.abs(weight);
weight_sum += weight;
}
}
double succ_chance = (weight_sum / weight_total) + 0.15;
if(Math.random() <= succ_chance)
success = true;
}
// Do more stuff....
}
Does this affect performance? Is it against convention? Would doing this be frowned upon in a professional environment?