The only thing worse than code written using The Wrong Brace Style(tm)
-
Well which one don't you like?
Well fads they come and fads they go. And God I love that rock and roll! Well the point was fast but it was too blunt to miss. Life handed us a paycheck, we said, "We worked harder than this!"
The wrong one, of course.
The difficult we do right away... ...the impossible takes slightly longer.
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
ctrl+e+d reformats according to your VS settings.
Never underestimate the power of human stupidity RAH
-
ctrl+e+d reformats according to your VS settings.
Never underestimate the power of human stupidity RAH
- Unfortunately VS doesn't support targeting CackBerry 1) I have to use a rimmed version of Eclipse FILE_NOT_FOUND: No posting constructive replies to an obvious venting session
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
The wrong one, of course.
The difficult we do right away... ...the impossible takes slightly longer.
Exactly.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
Dan Neely wrote:
Some opening braces on their own line; others on the preceding line.
The real question is does the code function properly? :rolleyes:
The report of my death was an exaggeration - Mark Twain
Simply Elegant Designs JimmyRopes Designs
Think inside the box! ProActive Secure Systems
I'm on-line therefore I am. JimmyRopes -
- Unfortunately VS doesn't support targeting CackBerry 1) I have to use a rimmed version of Eclipse FILE_NOT_FOUND: No posting constructive replies to an obvious venting session
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
Dan Neely wrote:
FILE_NOT_FOUND: No posting constructive replies to an obvious venting session
Yeah, sorry, nasty habit pissing on a good rant :-O
Never underestimate the power of human stupidity RAH
-
Dan Neely wrote:
Some opening braces on their own line; others on the preceding line.
The real question is does the code function properly? :rolleyes:
The report of my death was an exaggeration - Mark Twain
Simply Elegant Designs JimmyRopes Designs
Think inside the box! ProActive Secure Systems
I'm on-line therefore I am. JimmyRopesJimmyRopes wrote:
The real question is does the code function properly? :rolleyes:
Which part of...
Quote:
For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform
... id you not understand?
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
OriginalGriff wrote:
Reformat the whole lot to Whitesmiths style!
I came to C/C++ from turbo pascal - so naturally I did C/C++ in the Whitesmiths style ... I still guess that the primary reason for
void foo() {
}was the 12" monitors of yesteryears ... On the other hand, I guess the best reason for having a coding style-guide is to avoid wasting time discussing coding styles.
Espen Harlinn Principal Architect, Software - Goodtech Projects & Services AS Projects promoting programming in "natural language" are intrinsically doomed to fail. Edsger W.Dijkstra
Whitesmith's rules! I never seize to amaze over the triviality of this eternal style format discussion. Who is to say one style is better or worse than another? Is it not more important that the code is A. readable, B. intuitive, C. Bug Free! What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart. This entire theme of discussion is in my years of writing code simply for small talk on coffee breaks and not really adding functionality in my personal opinion.
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
...I don't see a problem here! Does that make me a bad person?
Well fads they come and fads they go. And God I love that rock and roll! Well the point was fast but it was too blunt to miss. Life handed us a paycheck, we said, "We worked harder than this!"
You were already bad, don't try to fool us...
[www.tamautomation.com] | Robots, CNC and PLC machines for grinding and polishing. [YouTube channel]
-
JimmyRopes wrote:
The real question is does the code function properly? :rolleyes:
Which part of...
Quote:
For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform
... id you not understand?
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
Dan Neely wrote:
Which part of...For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform...id you not understand?
I id understand you were porting it to a BB10 platform which makes it important that the code functions properly or you will be porting code that does not meet the functionality of the application. Which part of...
JimmyRopes wrote:
The real question is does the code function properly? :rolleyes:
... id you not understand? :doh:
The report of my death was an exaggeration - Mark Twain
Simply Elegant Designs JimmyRopes Designs
Think inside the box! ProActive Secure Systems
I'm on-line therefore I am. JimmyRopes -
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
To me there often is much more to get upset on than brace styles. I can deal with every style (as long as it is the same style in the whole module of course). Meaningless variable names or code with a lot of untreated warnings from the compiler (deserts of trivial to solve warnings hiding the really important one) - that drives me nuts! Brace styles? No, not really...
-
Whitesmith's rules! I never seize to amaze over the triviality of this eternal style format discussion. Who is to say one style is better or worse than another? Is it not more important that the code is A. readable, B. intuitive, C. Bug Free! What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart. This entire theme of discussion is in my years of writing code simply for small talk on coffee breaks and not really adding functionality in my personal opinion.
MRJIT wrote:
What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart.
Oddly, what I truly detest in coding style is the code packed so tightly as to be completely inscrutable to any other programmer --- to appear smart.
Truth, James
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
This is K&R - other than the if (appPage) not needing braces at all. Nothing wrong here. Move along.
-
Whitesmith's rules! I never seize to amaze over the triviality of this eternal style format discussion. Who is to say one style is better or worse than another? Is it not more important that the code is A. readable, B. intuitive, C. Bug Free! What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart. This entire theme of discussion is in my years of writing code simply for small talk on coffee breaks and not really adding functionality in my personal opinion.
MRJIT wrote:
Is it not more important that the code is A. readable...
Yes readability does matter, and that's exactly why brace style matters.
MRJIT wrote:
What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart.
I have never understood the desire to save vertical space. Can anyone tell me why, in this day and age, vertical space is so important that it's worth sacrificing readability for? The best brace style is the most readable one, and also the one that is least likely to get mangled during refactoring. Allman, of course.
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
Well, at least you have braces, they could have resorted to not use braces in the last if. :)
CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
The Sherlock comments are certainly annoying. //Add a and b var result = a + b; //Save the result result.Save(); // Mønti Pythøn ik den Hølie Gräilen Røtern nik Akten Di Wik Alsø wik Alsø alsø wik Wi nøt trei // a høliday in Sweden this yër? See the løveli lakes The wøndërful telephøne system And mäni // interesting furry animals The characters and incidents portrayed and the names used are fictitious // and any similarity to the names, characters, or history of any person is entirely accidental and // unintentional. System.Diagnostics.Debug.WriteLine(result.ToString());
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
-
Whitesmith's rules! I never seize to amaze over the triviality of this eternal style format discussion. Who is to say one style is better or worse than another? Is it not more important that the code is A. readable, B. intuitive, C. Bug Free! What I truly detest in coding style is all the code written as if programmers were paid by each line of code (ancient format of reimbursement) and everyone simply tries to fill a load of dead line space whilst appearing smart. This entire theme of discussion is in my years of writing code simply for small talk on coffee breaks and not really adding functionality in my personal opinion.
IMHO - the goal of formatting is to make the structure of the code visible, explicit, so the reader does not have to dig into the code and try to decipher its structure. Some people have the naive view that formatting as merely "pretty printing" or making the code neat and tidy. This leads to inconsistent formatting conventions and the mistaken idea that formatting is a matter of individual style rather than an engineering topic. Making the code pretty with an individual style only accomplishes half of the goal of making the structure explicit. It does not provide a basis for a consistent set of guidelines for the formatting.
-
... is code that is written using a mix of brace styles. For my sins I'm investigating the possibility of porting one of my employer's apps to the BB10 platform; and most of the sample app code they've provided looks like this:
PhotoBomberApp::PhotoBomberApp()
{
// Create a QMLDocument and load it, using build patterns
QmlDocument *qml = QmlDocument::create("asset:///main.qml");qml->setContextProperty("\_photoBomber", this); if (!qml->hasErrors()) { // The application Page is created from QML. Page \*appPage = qml->createRootObject<Page>(); if (appPage) { // Set the application scene. Application::instance()->setScene(appPage); } }
}
Some opening braces on their own line; others on the preceding line. **SPEW**[^]
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt
The only answer is to switch to Fortran. If you still complain about K&R style after that, then you are far more resilient than I. :)