Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Yet another style discussion? Is there not a format tool?

Yet another style discussion? Is there not a format tool?

Scheduled Pinned Locked Moved The Lounge
questionvisual-studiohelpdiscussion
29 Posts 20 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P peterchen

    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

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #15

    peterchen 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.

    1 Reply Last reply
    0
    • E Ennis Ray Lynch Jr

      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

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #16

      I hadn't thought of that; good point. :thumbsup:

      1 Reply Last reply
      0
      • N Nagy Vilmos

        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

        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #17

        Nagy Vilmos wrote:

        make the code clear to understand

        I do, but still I get down-voted for my style. :sigh:

        N 1 Reply Last reply
        0
        • P PIEBALDconsult

          Nagy Vilmos wrote:

          make the code clear to understand

          I do, but still I get down-voted for my style. :sigh:

          N Offline
          N Offline
          Nelek
          wrote on last edited by
          #18

          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.

          1 Reply Last reply
          0
          • E Ennis Ray Lynch Jr

            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

            N Offline
            N Offline
            Nelek
            wrote on last edited by
            #19

            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.

            1 Reply Last reply
            0
            • G Gary Huck

              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?

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #20

              GamleKoder wrote:

              Is there not a format tool?

              Yes[^]. /ravi

              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

              1 Reply Last reply
              0
              • P peterchen

                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

                P Offline
                P Offline
                Patrice STOESSEL
                wrote on last edited by
                #21

                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

                R D 2 Replies Last reply
                0
                • E Ennis Ray Lynch Jr

                  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

                  M Offline
                  M Offline
                  Magnamus
                  wrote on last edited by
                  #22

                  I like that your text is an example of the content it describes :)

                  1 Reply Last reply
                  0
                  • N Nagy Vilmos

                    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

                    F Offline
                    F Offline
                    Fabio Franco
                    wrote on last edited by
                    #23

                    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

                    1 Reply Last reply
                    0
                    • G Gary Huck

                      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?

                      R Offline
                      R Offline
                      Rob Grainger
                      wrote on last edited by
                      #24

                      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.

                      1 Reply Last reply
                      0
                      • P Patrice STOESSEL

                        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

                        R Offline
                        R Offline
                        Rob Grainger
                        wrote on last edited by
                        #25

                        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.

                        1 Reply Last reply
                        0
                        • D David Crow

                          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

                          O Offline
                          O Offline
                          onemorechance
                          wrote on last edited by
                          #26

                          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.

                          1 Reply Last reply
                          0
                          • P Patrice STOESSEL

                            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

                            D Offline
                            D Offline
                            djdanlib 0
                            wrote on last edited by
                            #27

                            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.

                            1 Reply Last reply
                            0
                            • E Ennis Ray Lynch Jr

                              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

                              F Offline
                              F Offline
                              Fabio Franco
                              wrote on last edited by
                              #28

                              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?

                              I think what he posted here already defeats the idea of loosing original developer's formatting. Such a tool would take the original document, and say, display a space character instead of a line feed character before a bracket, without actually modifying the original file. Such a tool would also detect that the original file was using line feed for opening brackets and would save it back this way, so still not changing the original developer's formatting, while displaying the format the way the current user likes. Additionally, this could make possible a company wide standard, where all their files contain a single default standard and still allow different developers to have it viewed the same way, even inside the same team, without anyone complaining: "Who messed up my code's formatting?" I actually think that's a very interesting idea.

                              "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

                              1 Reply Last reply
                              0
                              • G Gary Huck

                                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?

                                S Offline
                                S Offline
                                SeattleC
                                wrote on last edited by
                                #29

                                As long as team members disagree on style, reformatters cannot answer the style question. It would result in a continuous war of style rewrites, resulting in checkins affecting virtually every line. I personally think formatters can never answer the style question, because software development is a visual art, like painting, in addition to everything else that it is. I write my programs in a certain style because I want them to look a certain way. My code expresses my personal creativity. It's a very personal thing. Reformatting my program is as aesthetically displeasing as painting a few new angels on the sistine chapel. Agreeing to a common set of style choices provides a framework that lets each member satisfy their need for visual-artistic control, while avoiding the artistic insult of reformatting. Team members may still disagree on aesthetic details, but the common rules give them space within which to work, just as a poetic style or musical genre does. Attempts have been made to develop programming lanugages with a canonical indentation style to reduce variation (e.g. comb style in Ada), and there have been programming languages that stored and rerendered your code in a cononical form (e.g. old microsoft BASIC). These efforts are successful at reducing variation, but there is still a lot of wiggle-room for individual style. Anyone remember the trick of beginning a line of BASIC with ':' to keep the parser from removing spaces and letting you express indentation? How about indents, paragraph style, and header rows of '******' or '=====' in comments? Style wars may also express ego in team situations. They may be used as a distraction from work. They may occur for reasons that have nothing to do with the code. Give it up. You'll never get rid of style wars.

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups