Almost all the code I've seen until now uses the following style for curly braces:
void swap(int &a, int &b)
{
int temp = a;
a = b;
b = temp;
}
Visual Studio also defaults to this. However I have read Code Complete 2nd edition and Steve McConnell argues against this style. "Avoid unindented being-end pairs (...) Although this approach looks fine, it (...) doesn't show the logical structure of the code. Used this way, the begin and end aren't part of the control construct, but they aren't part of the statements after it either." Steve McConnell recommends using the pure block style, which emulates Visual Basic (where there's no curly braces):
void swap(int &a, int &b) {
int temp = a;
a = b;
b = temp;
}
or this (begin-end block boundaries):
void swap(int &a, int &b)
{
int temp = a;
a = b;
b = temp;
}
Although I tend to agree with McConnell's reasoning, all the books I read, the classes I attended, and Visual Studio, use the first style, so I find it a bit weird. What do you think?
Payday 2 engine upgrade adds 64-bit and DX11 support, drastically shrinks install size by Pulasthi Ariyasinghe
Payday 2, the most popular entry in the heisting game franchise, is getting a surprising update after all these years. This is slated to be a complete engine upgrade that will enhance almost every aspect of the 13-year-old title, targeting performance, loading times, file size, rendering backend, and more. Developer Sidetrack Games is planning a beta to test out the new version ahead of the full public launch.
The development team today revealed that the long-awaited upgrade to the 64-bit architecture is happening with this Diesel 3.0 engine update. By letting the game use more ram than 4GB, it is said to improve stability and compatibility on most hardware. It should also help modders in the long term with implementing larger changes too.
"While many of the changes are made on the backend and not everything will be visible to you guys because it is a massive rewrite of the entire codebase, there will be a lot of things that you can look forward to," Sidetrack explained.
Payday 2 will also hop over from DirectX 9 to 11. Instead of visual improvements, this is slated to reduce the amount of VRAM used by the title, letting more lower-end hardware access the title and run it better.
Since these changes would require a complete redownload of the game anyway, Sidetrack says it has revamped "the game's packaging and bundling system." This should reduce the installation size from 86GB to 32GB. "So, now it's time to finally move the game to your SSDs," added the studio.
The Payday 2 Diesel Engine 3.0 update is entering open beta on June 30 for Steam users. No console release plans were announced today.
Sidetrack Games says it has been working on this complete rewrite of the codebase for the last nine months. While these changes should break most mods, the studio encouraged modders to use the beta period to repair their creations with support from the development team.
Question
Andre S. Veteran
Almost all the code I've seen until now uses the following style for curly braces:
void swap(int &a, int &b) { int temp = a; a = b; b = temp; }Visual Studio also defaults to this. However I have read Code Complete 2nd edition and Steve McConnell argues against this style. "Avoid unindented being-end pairs (...) Although this approach looks fine, it (...) doesn't show the logical structure of the code. Used this way, the begin and end aren't part of the control construct, but they aren't part of the statements after it either." Steve McConnell recommends using the pure block style, which emulates Visual Basic (where there's no curly braces):
void swap(int &a, int &b) { int temp = a; a = b; b = temp; }or this (begin-end block boundaries):
void swap(int &a, int &b) { int temp = a; a = b; b = temp; }Although I tend to agree with McConnell's reasoning, all the books I read, the classes I attended, and Visual Studio, use the first style, so I find it a bit weird. What do you think?
Link to comment
https://www.neowin.net/forum/topic/630296-curly-braces-placement-and-indentation/Share on other sites
63 answers to this question
Recommended Posts