One thing I really like about IDEs is the ability to "minimize" sections of code, so that:
while(conditions){
// Really long code...
}
Can become:
while(conditions){ // The rest is hidden
My question is whether or not something like this would be acceptable formatting
// Code
{
// More code
}
// Code
I understand that anything done inside the brackets would have that limited scope, but I can also edit variables in the outer scope as well.
So, for a short, unnecessary example
int x = 1;
{ // Create new variable, add and output
int y = 2;
cout << x + y;
}
Would become:
int x = 1;
{ // Create new variable, add and output (The rest of the code is hidden)
So would this be acceptable, or shunned?
Here is a real example of something I would want to just hide.
/// Add line to msg vector
// Check to see if each side X is needed
if(uniqueSide && line == 1){
// Create stringstream to hold string and int (e.g. "Message " + 1 + " - Side " + 1
stringstream tempString;
// Add full line to stringstream. validMessages.length() + 1 will make Message X be incremental
tempString << "Message " << (validMessages.length() + 1) << " - Side " << numSide;
// Then append full string (e.g. "Message 1 - Side 1") to msg
msg.append(tempString.str());
}
// Else just add Message X using same method as above
else if(line == 1){
stringstream tempString;
tempString << "Message " << (validMessages.length() + 1);
}
// Add each line to msg vector with double space indent and (width) before each line
stringstream tempString;
tempString << setprecision(5) // Makes width be output as 10.325 or 100.33
<< " (" << width << ") " << tempInput
msg.append(tempString.str());
Thanks.