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. Tools for enforcing coding guidelines?

Tools for enforcing coding guidelines?

Scheduled Pinned Locked Moved The Lounge
algorithmscollaborationtoolsquestion
24 Posts 17 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.
  • G Gary R Wheeler

    If your coding standards document is longer than a page or two, you're doing it wrong. Our standards document is a 1.5 pages, including samples. We've used it for over ten years, developed a half dozen products, and built a body of several million lines of code. All of this from a group that has ranged from four to ten people over the period.

    Software Zen: delete this;

    C Offline
    C Offline
    charlieg
    wrote on last edited by
    #11

    Maybe someone will blunder across this thread... The thing is that I have to play the hand I'm dealt. Nobody, I mean nobody is challenging anything being said.

    Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

    G 1 Reply Last reply
    0
    • C charlieg

      Okay, so the team I'm working with has decided to go all process and that. Don't get me wrong, they are a good team, I just have reservations about having perfect source code and no product. They were set loose to derive a document for coding - 60+ pages later, I am afraid. Any recommendations for reasonably affordable tools that could be set up to cull the drudge work? Still searching - sort of - I've been working on code.

      Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

      M Offline
      M Offline
      Mark_Wallace
      wrote on last edited by
      #12

      The only really effective method involves whips and chains (metaphorically), and lots of pain (not so metaphorically). A better way to go involves questions like "Hey, Steve, are you saying that if Geoff puts his braces on a new line, you can't understand the code?", and mentioning that more advanced developers, several of which are available for hire, might not have that problem.

      I wanna be a eunuchs developer! Pass me a bread knife!

      1 Reply Last reply
      0
      • C charlieg

        Okay, so the team I'm working with has decided to go all process and that. Don't get me wrong, they are a good team, I just have reservations about having perfect source code and no product. They were set loose to derive a document for coding - 60+ pages later, I am afraid. Any recommendations for reasonably affordable tools that could be set up to cull the drudge work? Still searching - sort of - I've been working on code.

        Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

        J Offline
        J Offline
        jsc42
        wrote on last edited by
        #13

        Have you tried a baseball bat? The use of this tool quickly makes people adhere to standards. If that fails, try lobotomies. Your BF quote in you signature block:

        charlieg wrote:

        They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety

        is a fair summary of what adherence to arbitrarily derived guidelines is about - giving up liberty to obtain a little temporary safety. If we had adhered to guidelines, all of our code would still be daubs of blood and plant extracts on cave walls. People need freedom to experiment and to advance. That is how progress takes place.

        C P 2 Replies Last reply
        0
        • J jsc42

          Have you tried a baseball bat? The use of this tool quickly makes people adhere to standards. If that fails, try lobotomies. Your BF quote in you signature block:

          charlieg wrote:

          They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety

          is a fair summary of what adherence to arbitrarily derived guidelines is about - giving up liberty to obtain a little temporary safety. If we had adhered to guidelines, all of our code would still be daubs of blood and plant extracts on cave walls. People need freedom to experiment and to advance. That is how progress takes place.

          C Offline
          C Offline
          charlieg
          wrote on last edited by
          #14

          Not arguing, but I'm the mercenary here....

          Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

          1 Reply Last reply
          0
          • C charlieg

            Maybe someone will blunder across this thread... The thing is that I have to play the hand I'm dealt. Nobody, I mean nobody is challenging anything being said.

            Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

            G Offline
            G Offline
            Gary Wheeler
            wrote on last edited by
            #15

            Unless this opus is documenting and codifying existing practice, this does not bode well. If this is being imposed by management, I'd advocate polishing your resume and getting out. I was in this situation a few years ago. We were placed under a hardware engineer who didn't understand software development, didn't like it, and thought he could convert our process into a "turn-the-crank" operation through a bunch of lean practices garbage he'd picked up in some book. Needless to say, it was a disaster. In a rare moment of clarity, someone high up figured out this was A Bad Idea and we were moved elsewhere in the org chart.

            Software Zen: delete this;

            1 Reply Last reply
            0
            • C charlieg

              Okay, so the team I'm working with has decided to go all process and that. Don't get me wrong, they are a good team, I just have reservations about having perfect source code and no product. They were set loose to derive a document for coding - 60+ pages later, I am afraid. Any recommendations for reasonably affordable tools that could be set up to cull the drudge work? Still searching - sort of - I've been working on code.

              Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

              K Offline
              K Offline
              kalberts
              wrote on last edited by
              #16

              It all depends on what you want to enforce, and also to some degreen on your programming language(s). I am responsible for a medium size project (an internal tool) written in C# in VS, that is being updated by about half a dozen people who develop their own extensions, but before they are released to others, I look through it. "Unfortunately" I have a tendency to delete the final closing brace, so I have to type it in again. And then, unfortunately, the code layout is automatically adjusted to the style I have set up. When Visual Studio reformats the code, it happens that end-of-line comments (that I am very fond of myself) need a little straightening up to make a nice, straight column. But if somebody comments on the reformatting, I put up a really sad face, "I am sorry, that happened automatically when I looked through your code..." (it didn't take them long to learn, though). We also have an SVN precommit-hook verifying that no source file contains any tab characters, and our build scripts always run lint on C code (which is used in several other projects). For C# we don't have lint, but when I review added/updated code, I always compile it, and expect it to compile with no errors and no warnings. If they do occur, and I cannot easily fix it there on the spot, I return the code to the developer. Obviously this doesn't handle naming conventions and stuff like that. When I review the code, it happens that I use the F2 key, Refactor/Rename, e.g. to change use of underscores to CamelCase (or PascalCase). More extensive things, like comment blocks explaining the purpose and structure of a module. But don't expect a tool to be able to do much more than I can do when reviewing the code (i.e. telling the developer to add what is missing). Actually, once the code layout questions are settled (through VS reformatting), the fierce arguments over coding guidelines tend to calm down so much that it is possible to have a civilized discussion about good naming principles etc. Bottom line: You can get a whole lot "for free" (almost), at least if you happen to be using VS, and in particular with C#.

              C 1 Reply Last reply
              0
              • C charlieg

                Okay, so the team I'm working with has decided to go all process and that. Don't get me wrong, they are a good team, I just have reservations about having perfect source code and no product. They were set loose to derive a document for coding - 60+ pages later, I am afraid. Any recommendations for reasonably affordable tools that could be set up to cull the drudge work? Still searching - sort of - I've been working on code.

                Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                E Offline
                E Offline
                ENOTTY
                wrote on last edited by
                #17

                Clue_Stick[^]

                B 1 Reply Last reply
                0
                • C charlieg

                  Okay, so the team I'm working with has decided to go all process and that. Don't get me wrong, they are a good team, I just have reservations about having perfect source code and no product. They were set loose to derive a document for coding - 60+ pages later, I am afraid. Any recommendations for reasonably affordable tools that could be set up to cull the drudge work? Still searching - sort of - I've been working on code.

                  Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                  A Offline
                  A Offline
                  alex barylski
                  wrote on last edited by
                  #18

                  Code Sniffer is what you likely want to search for - PHP has a great one. :) The premise is simple, use a tokenizer, and the write custom rules for what is valid according to convention. No external documents necessary, the CS files act as pre-compile tests. An additional bonus, is the ability to hook this into VCS (ie: Subversion) in pre-phase and stop code from every making it into the repo until it passes convention tests and automated verification. It's more work than I leading on, but well worth the pay off in the end, if quality is important to you. Alex

                  1 Reply Last reply
                  0
                  • C charlieg

                    Okay, so the team I'm working with has decided to go all process and that. Don't get me wrong, they are a good team, I just have reservations about having perfect source code and no product. They were set loose to derive a document for coding - 60+ pages later, I am afraid. Any recommendations for reasonably affordable tools that could be set up to cull the drudge work? Still searching - sort of - I've been working on code.

                    Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                    J Offline
                    J Offline
                    Joe Woodbury
                    wrote on last edited by
                    #19

                    Depends on the language. For C#, ReSharper will flag guideline violations and let you reformat code. The team I'm on has already agreed on some basic guidelines for consistency sake (how to name data members is the single biggest argument point.) In places where we can't comply without great pain (some serialized classes) we add "Resharper ignore this" comments. I've been fortunate in that my previous three team leads and most the team had a similar enough coding style with one glaring exception (one guy had the weirdest indentation style and a near obsession with nested if statements) that our style was "whatever we're already doing." The code I'm working on now has been touched by so many developers with different styles that it's a formatted mess. This has a definite negative impact on productivity.

                    1 Reply Last reply
                    0
                    • K kalberts

                      It all depends on what you want to enforce, and also to some degreen on your programming language(s). I am responsible for a medium size project (an internal tool) written in C# in VS, that is being updated by about half a dozen people who develop their own extensions, but before they are released to others, I look through it. "Unfortunately" I have a tendency to delete the final closing brace, so I have to type it in again. And then, unfortunately, the code layout is automatically adjusted to the style I have set up. When Visual Studio reformats the code, it happens that end-of-line comments (that I am very fond of myself) need a little straightening up to make a nice, straight column. But if somebody comments on the reformatting, I put up a really sad face, "I am sorry, that happened automatically when I looked through your code..." (it didn't take them long to learn, though). We also have an SVN precommit-hook verifying that no source file contains any tab characters, and our build scripts always run lint on C code (which is used in several other projects). For C# we don't have lint, but when I review added/updated code, I always compile it, and expect it to compile with no errors and no warnings. If they do occur, and I cannot easily fix it there on the spot, I return the code to the developer. Obviously this doesn't handle naming conventions and stuff like that. When I review the code, it happens that I use the F2 key, Refactor/Rename, e.g. to change use of underscores to CamelCase (or PascalCase). More extensive things, like comment blocks explaining the purpose and structure of a module. But don't expect a tool to be able to do much more than I can do when reviewing the code (i.e. telling the developer to add what is missing). Actually, once the code layout questions are settled (through VS reformatting), the fierce arguments over coding guidelines tend to calm down so much that it is possible to have a civilized discussion about good naming principles etc. Bottom line: You can get a whole lot "for free" (almost), at least if you happen to be using VS, and in particular with C#.

                      C Offline
                      C Offline
                      charlieg
                      wrote on last edited by
                      #20

                      We also have an SVN precommit-hook verifying that no source file contains any tab characters, and our build scripts always run lint on C code (which is used in several other projects).

                      That is a great idea. We're mainly a C/C++ shop with some C# tossed in. I'll have to look into that.

                      Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                      1 Reply Last reply
                      0
                      • C charlieg

                        Okay, so the team I'm working with has decided to go all process and that. Don't get me wrong, they are a good team, I just have reservations about having perfect source code and no product. They were set loose to derive a document for coding - 60+ pages later, I am afraid. Any recommendations for reasonably affordable tools that could be set up to cull the drudge work? Still searching - sort of - I've been working on code.

                        Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                        R Offline
                        R Offline
                        RafagaX
                        wrote on last edited by
                        #21

                        60 pages?, at 6 pages I would have been deeply worried... :omg:

                        CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                        C 1 Reply Last reply
                        0
                        • J jsc42

                          Have you tried a baseball bat? The use of this tool quickly makes people adhere to standards. If that fails, try lobotomies. Your BF quote in you signature block:

                          charlieg wrote:

                          They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety

                          is a fair summary of what adherence to arbitrarily derived guidelines is about - giving up liberty to obtain a little temporary safety. If we had adhered to guidelines, all of our code would still be daubs of blood and plant extracts on cave walls. People need freedom to experiment and to advance. That is how progress takes place.

                          P Offline
                          P Offline
                          pdohara
                          wrote on last edited by
                          #22

                          I've used the baseball bat approach. (No really I have) and it worked well for about a month. Even within that month I saw the slip back to old habits. You cannot force people to write good code.

                          Tanks for your support
                          Pat O
                          Blog

                          _ _ _
                          /*\== /*\== /*\==

                          1 Reply Last reply
                          0
                          • E ENOTTY

                            Clue_Stick[^]

                            B Offline
                            B Offline
                            BrainiacV
                            wrote on last edited by
                            #23

                            See Kodak Motivational Carrot[^] lower on the page.

                            Psychosis at 10 Film at 11 Those who do not remember the past, are doomed to repeat it. Those who do not remember the past, cannot build upon it.

                            1 Reply Last reply
                            0
                            • R RafagaX

                              60 pages?, at 6 pages I would have been deeply worried... :omg:

                              CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                              C Offline
                              C Offline
                              charlieg
                              wrote on last edited by
                              #24

                              Happily I have learned that they have agreed to reducing it from 62 pages to under 3. That's a serious reduction.

                              Charlie Gilley You're going to tell me what I want to know, or I'm going to beat you to death in your own house. "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                              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