Yet another style discussion? Is there not a format tool?
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
GamleKoder wrote:
Would such a tool not render any such discussion moot?
No. It would actually have no effect on such discussions. The only thing such a tool would accomplish is to make formatting the code that much faster, but folks would still have their opinion as to what that format is.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
GamleKoder wrote:
Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking?
Almost. However, readability sometimes prefers violation of the "standard" format.
GamleKoder wrote:
Would such a tool not render any such discussion moot?
Hard/Hardly. "Making this discussion moot" would mean everyone can commit code as he likes, but also sees it only as he likes. That would roughly require reformatting code automatically when you fetch from source control, so you locally see it only in "your" format, no other. This would have to be integrated into your version control client, otherwise diffs are messed up royally. Worst, this would likely touch all files, triggering a rebuild of the universe. Worserst, Reading code is pretty hard and often undertrained. Letting devs see only their preferred formatting makes them dependent on that tool.
Not enough? Just for a few seconds, imagine an obscure bug/not-very-well-understood-feature in the formatter, that changes the codes behavior depending on the formatting options set. Bug present on Joe's PC, but noone elses. Even if Joe fixes the bug, it may come back from someone others "cleanup". Yuck.
FILETIME to time_t
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchy -
Nagy Vilmos wrote:
It isn't very difficult. Well written clear code IS better. It is easier to maintain and that makes YOUR job better. Would you rather debug shít or expand gold?
Well said! Seems like something slipped by the censors?
VS2010/Atmel Studio 6.0 ToDo Manager Extension
Version 3.0 now available.If you is clever, you can change vowels - áéíóú - and the hamsters get confused. They basically think that anything with an accent is French and the stop reading out of disgust.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
VS will do it for you, provided there are no critical errors: CTRL+K D will do it by default. The only hassle is that re-formatting documents may count as a change as far as source control is concerned - even if there are no other changes.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
Well, if you want the tool that does it for XAML, some modest but very clever chappy released a Visual Studio addin that already does this[^].
*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington
"Mind bleach! Send me mind bleach!" - Nagy Vilmos
My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
GamleKoder wrote:
Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking?
No. Some try, but there are too many preferences. The only such thing I have used is what's in Visual Studio; it allows me to set most of my preferences, but not all.
GamleKoder wrote:
pull up a file, hit the special key and presto, the code is formatted to one's liking
That might be fine when you download some code from an article here, but not so good for code written by your co-workers and stored in a version control system. And basically it's a false premise; even if someone ever writes the ultimate IDE which handles every possible combination of preferences, not everyone will use it. I won't use it if it isn't free. Can I use it on OpenVMS or other non-Windows operating systems? While I do use Visual Studio for WinForms applications, I don't use it for quick little console applications and parts of my library that just don't require the services of a full-blown IDE. For most of what I do I use a simple text editor that loads and unloads quickly and doesn't require a bunch of support files (solutions, projects, etc.) just to write some code.
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
What people fail to understand about reformatting tools is they lose the original developers formatting. I would much rather have each developer have his or her own style that is close in line with what I want than every one writing identical code. The rationale: during code reviews code formatting helps me determine what kind of errors to expect. You can tell a lot about a person about what formatting they chose at the time, where they in a rush? Was there thinking unclear? Formatting really helps show that. Unfortunately, MS products are business tools and in business the justification is that every person is a replaceable tool and every line of code from every developer should be interchangeable and identical. Wrong!
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
-
GamleKoder wrote:
Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking?
Almost. However, readability sometimes prefers violation of the "standard" format.
GamleKoder wrote:
Would such a tool not render any such discussion moot?
Hard/Hardly. "Making this discussion moot" would mean everyone can commit code as he likes, but also sees it only as he likes. That would roughly require reformatting code automatically when you fetch from source control, so you locally see it only in "your" format, no other. This would have to be integrated into your version control client, otherwise diffs are messed up royally. Worst, this would likely touch all files, triggering a rebuild of the universe. Worserst, Reading code is pretty hard and often undertrained. Letting devs see only their preferred formatting makes them dependent on that tool.
Not enough? Just for a few seconds, imagine an obscure bug/not-very-well-understood-feature in the formatter, that changes the codes behavior depending on the formatting options set. Bug present on Joe's PC, but noone elses. Even if Joe fixes the bug, it may come back from someone others "cleanup". Yuck.
FILETIME to time_t
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchypeterchen wrote:
makes them dependent on that tool
Right, that's the worst part; one should not become dependant on particular tools -- even if those tools are seen as the best.
-
What people fail to understand about reformatting tools is they lose the original developers formatting. I would much rather have each developer have his or her own style that is close in line with what I want than every one writing identical code. The rationale: during code reviews code formatting helps me determine what kind of errors to expect. You can tell a lot about a person about what formatting they chose at the time, where they in a rush? Was there thinking unclear? Formatting really helps show that. Unfortunately, MS products are business tools and in business the justification is that every person is a replaceable tool and every line of code from every developer should be interchangeable and identical. Wrong!
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
I hadn't thought of that; good point. :thumbsup:
-
I would argue for only one thing - make the code clear to understand. Who needs to understand it? You - then be lazy, why comment a private method when the name states what it does. Others - be consistent in what you write and with what the others write. It isn't very difficult. Well written clear code IS better. It is easier to maintain and that makes YOUR job better. Would you rather debug shít or expand gold?
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
Nagy Vilmos wrote:
make the code clear to understand
I do, but still I get down-voted for my style. :sigh:
-
Nagy Vilmos wrote:
make the code clear to understand
I do, but still I get down-voted for my style. :sigh:
Well... it is said that genious are missunderstood... are you the new Einstein? ;)
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.
-
What people fail to understand about reformatting tools is they lose the original developers formatting. I would much rather have each developer have his or her own style that is close in line with what I want than every one writing identical code. The rationale: during code reviews code formatting helps me determine what kind of errors to expect. You can tell a lot about a person about what formatting they chose at the time, where they in a rush? Was there thinking unclear? Formatting really helps show that. Unfortunately, MS products are business tools and in business the justification is that every person is a replaceable tool and every line of code from every developer should be interchangeable and identical. Wrong!
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
The best argument of the thread :thumbsup:
Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpfull answers is nice, but saying thanks can be even nicer.
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
-
GamleKoder wrote:
Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking?
Almost. However, readability sometimes prefers violation of the "standard" format.
GamleKoder wrote:
Would such a tool not render any such discussion moot?
Hard/Hardly. "Making this discussion moot" would mean everyone can commit code as he likes, but also sees it only as he likes. That would roughly require reformatting code automatically when you fetch from source control, so you locally see it only in "your" format, no other. This would have to be integrated into your version control client, otherwise diffs are messed up royally. Worst, this would likely touch all files, triggering a rebuild of the universe. Worserst, Reading code is pretty hard and often undertrained. Letting devs see only their preferred formatting makes them dependent on that tool.
Not enough? Just for a few seconds, imagine an obscure bug/not-very-well-understood-feature in the formatter, that changes the codes behavior depending on the formatting options set. Bug present on Joe's PC, but noone elses. Even if Joe fixes the bug, it may come back from someone others "cleanup". Yuck.
FILETIME to time_t
| FoldWithUs! | sighist | WhoIncludes - Analyzing C++ include file hierarchyRegarding the version control problem with reformating, it could be avoided if only AST (abstract syntax tree) of the program is saved. Then viewing a file becomes rendering the AST with the programmer's local preferences. And compilation, static analysis, etc would become much easier and faster. I guess that will happen one day. Right now, a browser rendering a HTML file does a little bit of this. Or for instance, rendering a XML file with a XSLT file
gzo
-
What people fail to understand about reformatting tools is they lose the original developers formatting. I would much rather have each developer have his or her own style that is close in line with what I want than every one writing identical code. The rationale: during code reviews code formatting helps me determine what kind of errors to expect. You can tell a lot about a person about what formatting they chose at the time, where they in a rush? Was there thinking unclear? Formatting really helps show that. Unfortunately, MS products are business tools and in business the justification is that every person is a replaceable tool and every line of code from every developer should be interchangeable and identical. Wrong!
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. I also do Android Programming as I find it a refreshing break from the MS. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost
-
Every shop I've worked in, and there have been quite a few, has had different standards. At the end of the day, we all have a preferred style but not one of them is perfect. By consensus, you agree on one style and then everyone sticks to it. I'm sorry, you may prefer tabs and I like four spaces. I want braces opening at the end of lines, you want them on separate lines. It does not matter a wasps fart! There are as many differnt styles[^] as there are programmers, get over it and get on with doing something useful.
Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
Nagy Vilmos wrote:
get over it and get on with doing something useful.
I think you missed the point completely. What he is wandering if there is or there should be an editor which automatically formats code according to user preferences, despite the way it's saved on text file. Such an editor could analyze the code file and display a bracket in front instead of next line and so on... It would be just a display thing, not necessarily replacing a new line character with a space.
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson "Our heads are round so our thoughts can change direction." ― Francis Picabia
-
Seems every day I read someone's post about style - braces, tabs vs. spaces [how many?], comments, blah, blah, blah? Is there not some tool that will allow us to take any "base" code or document and format to the individual's liking? Eg, pull up a file, hit the special key and presto, the code is formatted to one's liking. Would such a tool not render any such discussion moot? Proper commenting would still be an issue but the arguments over where to place braces or how many spaces to type could be retired. Such a tool must have been written [many times] - where/what is it?
In my experience that approach does not sit well with source control, unless the check in process automagically converts back to the company's "standard" preferences. At that stage, however, it becomes something more than just a quick "convert" option in the IDE, as we now need integration with SCC systems, etc.
-
Regarding the version control problem with reformating, it could be avoided if only AST (abstract syntax tree) of the program is saved. Then viewing a file becomes rendering the AST with the programmer's local preferences. And compilation, static analysis, etc would become much easier and faster. I guess that will happen one day. Right now, a browser rendering a HTML file does a little bit of this. Or for instance, rendering a XML file with a XSLT file
gzo
I believe Charles Simonyi left Microsoft to pursue something along those lines - he refers to his approach as Intentional Programming. Wikiepdia - Intentional Programming[^] I remember seeing a video demo in which he opens the same code in different languages "projections" - a step further than just formatting. Actually, it does a hell of a lot more than just that - incorporating DSL style ideas too. However, that was a few years ago and they seem quiet about everything, so don't get your hopes up.
-
GamleKoder wrote:
Would such a tool not render any such discussion moot?
No. It would actually have no effect on such discussions. The only thing such a tool would accomplish is to make formatting the code that much faster, but folks would still have their opinion as to what that format is.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
DavidCrow wrote:
The only thing such a tool would accomplish is to make formatting the code that much faster ...
Thus, leaving more time for them to drop by the forums and ride their hobby horse.
-
Regarding the version control problem with reformating, it could be avoided if only AST (abstract syntax tree) of the program is saved. Then viewing a file becomes rendering the AST with the programmer's local preferences. And compilation, static analysis, etc would become much easier and faster. I guess that will happen one day. Right now, a browser rendering a HTML file does a little bit of this. Or for instance, rendering a XML file with a XSLT file
gzo
If I had to save a valid AST every time, I'd never get all of my code written. I can't count how many times I've been trying to get a new concept sorted, ran out of time, and had to save an uncompilable piece of code. That also doesn't do anything for people who tab/space their comments to line up. It's a great concept but I doubt its implementation would satisfy people. In the end, everyone loves a good ego stroke, and they will find another battle to fight in the pursuit of that. Thank goodness it's only over spacing at this point, and that we're not arguing over those two One True Editors on UN*X / Linux anymore because we're using something else.