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. Intervention: Coding Guidelines

Intervention: Coding Guidelines

Scheduled Pinned Locked Moved The Lounge
csharpquestionc++visual-studiocode-review
74 Posts 33 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.
  • H honey the codewitch

    Halp! I've become a slave to naming and style guidelines. Years of C++ development and years of development prior to advanced compilers and syntax highlighting and intellisense and doc-comments and all of that made me a fascist about it. To the point where I judge people for not following, say, MS naming and style guidelines for .NET when building C# apps. To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc. I already smoke pot (it's legal here) so how do I loosen up? Y'all don't need my judgment. Nor do any fellow devs. And I need to be able to use other people's code without feeling a little sick about it, or wanting to refactor it before I touch it. I'm half serious about this post.

    When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

    P Offline
    P Offline
    PeejayAdams
    wrote on last edited by
    #8

    codewitch honey crisis wrote:

    To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc.

    I've never liked that one. Yes, I know it stops the "=" vs. "==" mistake but it just doesn't read the right way.

    Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain

    H J 2 Replies Last reply
    0
    • P PeejayAdams

      codewitch honey crisis wrote:

      To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc.

      I've never liked that one. Yes, I know it stops the "=" vs. "==" mistake but it just doesn't read the right way.

      Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain

      H Offline
      H Offline
      honey the codewitch
      wrote on last edited by
      #9

      I've grown to like it because if you tab everything out, it makes the constants easy to put into columns and read from the left. But that's only applicable when you're doing a lot of comparisons in one test, like in a state machine transition. Still, sometimes its elegant. Other times, maybe most times, i tend to agree with you but i suck it up and do it anyway, like eating an orange (i hate oranges)

      When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

      1 Reply Last reply
      0
      • H honey the codewitch

        Halp! I've become a slave to naming and style guidelines. Years of C++ development and years of development prior to advanced compilers and syntax highlighting and intellisense and doc-comments and all of that made me a fascist about it. To the point where I judge people for not following, say, MS naming and style guidelines for .NET when building C# apps. To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc. I already smoke pot (it's legal here) so how do I loosen up? Y'all don't need my judgment. Nor do any fellow devs. And I need to be able to use other people's code without feeling a little sick about it, or wanting to refactor it before I touch it. I'm half serious about this post.

        When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

        Z Offline
        Z Offline
        ZurdoDev
        wrote on last edited by
        #10

        codewitch honey crisis wrote:

        I'm half serious about this post.

        Which half?

        Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

        H 1 Reply Last reply
        0
        • H honey the codewitch

          Halp! I've become a slave to naming and style guidelines. Years of C++ development and years of development prior to advanced compilers and syntax highlighting and intellisense and doc-comments and all of that made me a fascist about it. To the point where I judge people for not following, say, MS naming and style guidelines for .NET when building C# apps. To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc. I already smoke pot (it's legal here) so how do I loosen up? Y'all don't need my judgment. Nor do any fellow devs. And I need to be able to use other people's code without feeling a little sick about it, or wanting to refactor it before I touch it. I'm half serious about this post.

          When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

          S Offline
          S Offline
          steveb
          wrote on last edited by
          #11

          Trust me, there's nothing wrong with dropping the source file into the notepad/vi and being able to tell right away whether some variables are member variables or local variables (thanks to conventions) without having to search the whole directory structure for its declaration. Especially if the project is > 1 million lines. Or looking at the equivalent of the namespace diarrhea where your fingers gets tired of searching here and there and comparing trying to put it all together in your head. :-D

          H 1 Reply Last reply
          0
          • S steveb

            Trust me, there's nothing wrong with dropping the source file into the notepad/vi and being able to tell right away whether some variables are member variables or local variables (thanks to conventions) without having to search the whole directory structure for its declaration. Especially if the project is > 1 million lines. Or looking at the equivalent of the namespace diarrhea where your fingers gets tired of searching here and there and comparing trying to put it all together in your head. :-D

            H Offline
            H Offline
            honey the codewitch
            wrote on last edited by
            #12

            i hear that!

            When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

            1 Reply Last reply
            0
            • Z ZurdoDev

              codewitch honey crisis wrote:

              I'm half serious about this post.

              Which half?

              Social Media - A platform that makes it easier for the crazies to find each other. Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.

              H Offline
              H Offline
              honey the codewitch
              wrote on last edited by
              #13

              I'm not sure

              When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

              1 Reply Last reply
              0
              • H honey the codewitch

                Halp! I've become a slave to naming and style guidelines. Years of C++ development and years of development prior to advanced compilers and syntax highlighting and intellisense and doc-comments and all of that made me a fascist about it. To the point where I judge people for not following, say, MS naming and style guidelines for .NET when building C# apps. To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc. I already smoke pot (it's legal here) so how do I loosen up? Y'all don't need my judgment. Nor do any fellow devs. And I need to be able to use other people's code without feeling a little sick about it, or wanting to refactor it before I touch it. I'm half serious about this post.

                When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #14

                this is how freedom smells in a socialist system. As long as you like it, it is great. :~

                Press F1 for help or google it. Greetings from Germany

                H 1 Reply Last reply
                0
                • H honey the codewitch

                  Halp! I've become a slave to naming and style guidelines. Years of C++ development and years of development prior to advanced compilers and syntax highlighting and intellisense and doc-comments and all of that made me a fascist about it. To the point where I judge people for not following, say, MS naming and style guidelines for .NET when building C# apps. To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc. I already smoke pot (it's legal here) so how do I loosen up? Y'all don't need my judgment. Nor do any fellow devs. And I need to be able to use other people's code without feeling a little sick about it, or wanting to refactor it before I touch it. I'm half serious about this post.

                  When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                  D Offline
                  D Offline
                  Daniel Pfeffer
                  wrote on last edited by
                  #15

                  I find coding styles to be like handwriting. When you've read enough code written by others, you'll find that you can read any style - as long as the writers followed it consistently. Life is too short to refactor everything into your preferred style.

                  Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                  M K 2 Replies Last reply
                  0
                  • H honey the codewitch

                    Halp! I've become a slave to naming and style guidelines. Years of C++ development and years of development prior to advanced compilers and syntax highlighting and intellisense and doc-comments and all of that made me a fascist about it. To the point where I judge people for not following, say, MS naming and style guidelines for .NET when building C# apps. To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc. I already smoke pot (it's legal here) so how do I loosen up? Y'all don't need my judgment. Nor do any fellow devs. And I need to be able to use other people's code without feeling a little sick about it, or wanting to refactor it before I touch it. I'm half serious about this post.

                    When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                    W Offline
                    W Offline
                    W Balboos GHB
                    wrote on last edited by
                    #16

                    codewitch honey crisis wrote:

                    I'm half serious about this post.

                    If you need to relax, work with the other not-so-serious half.

                    Ravings en masse^

                    "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                    "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                    1 Reply Last reply
                    0
                    • H honey the codewitch

                      I like standards. I'm button-down that way.

                      When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                      W Offline
                      W Offline
                      W Balboos GHB
                      wrote on last edited by
                      #17

                      There is only one (sensible) standard: The code can be read by another programmer without needing a decoder-ring - consistent with it's own standards and the intent of being informative to not only ones self, but with others who cares to look at the code. Consider that, even for a given language, a different type of project can be best served by code that is emphasizes its constructs as plainly (and maintainable) as possible. Also, if it's VB6, just chop off their hands.

                      Ravings en masse^

                      "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                      "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                      H 1 Reply Last reply
                      0
                      • H honey the codewitch

                        I like standards. I'm button-down that way.

                        When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

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

                        Coding standards are like religion.  It's fine to have one, but please don't force yours on me. :) /ravi

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

                        H R 2 Replies Last reply
                        0
                        • R Ravi Bhavnani

                          Coding standards are like religion.  It's fine to have one, but please don't force yours on me. :) /ravi

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

                          H Offline
                          H Offline
                          honey the codewitch
                          wrote on last edited by
                          #19

                          I am just trying to let go of some of my uptightness around the standards of others. =) We agree. I mean in principle. Intellectually speaking, but my heart isn't there yet.

                          When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                          R 1 Reply Last reply
                          0
                          • K KarstenK

                            this is how freedom smells in a socialist system. As long as you like it, it is great. :~

                            Press F1 for help or google it. Greetings from Germany

                            H Offline
                            H Offline
                            honey the codewitch
                            wrote on last edited by
                            #20

                            i'm not sure what any of this has to do with the workers owning and controlling the means of production (iow: socialism) it's just about my feelings around coding standards. sheesh

                            When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                            K 1 Reply Last reply
                            0
                            • P PeejayAdams

                              codewitch honey crisis wrote:

                              To the point where I usually kick myself for not putting constants before vars in equality comparisons if(0==foo), etc.

                              I've never liked that one. Yes, I know it stops the "=" vs. "==" mistake but it just doesn't read the right way.

                              Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain

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

                              It's a Catch-22 requirement. The rule is to help people who are unaware of the problem it is intended to solve. As soon as you are aware of the problem, you don't need the rule. As soon as you know the rule, you are aware of the problem so are unlikely to fall foul of it.

                              G 1 Reply Last reply
                              0
                              • H honey the codewitch

                                i'm not sure what any of this has to do with the workers owning and controlling the means of production (iow: socialism) it's just about my feelings around coding standards. sheesh

                                When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                                K Offline
                                K Offline
                                KarstenK
                                wrote on last edited by
                                #22

                                I lived in a socialist society and thats my feeling about. Owning means of production is not really essential in socialism, because there arent any profits from it. It brings only responsibilities to maintenance it. X|

                                Press F1 for help or google it. Greetings from Germany

                                H 1 Reply Last reply
                                0
                                • W W Balboos GHB

                                  There is only one (sensible) standard: The code can be read by another programmer without needing a decoder-ring - consistent with it's own standards and the intent of being informative to not only ones self, but with others who cares to look at the code. Consider that, even for a given language, a different type of project can be best served by code that is emphasizes its constructs as plainly (and maintainable) as possible. Also, if it's VB6, just chop off their hands.

                                  Ravings en masse^

                                  "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                                  "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                                  H Offline
                                  H Offline
                                  honey the codewitch
                                  wrote on last edited by
                                  #23

                                  all true, and yet the unsensible is perhaps underrated. some of the most inspirational bouts of coding I've had have left me with something I couldn't understand later. not that I appreciate that entirely. it is what it is. but yeah, I at least try to make the function names clean if it comes down to that. plus, have you ever noticed how sometimes, code as it matures can get a bunch of weird forks in its codepath to handle one-offs and bugs, sometimes in other systems its interacting with, and so the simplest, cleanest solution doesn't work in the real world. The truth is, I distrust all of this. It makes me uneasy. But it's a reality. The best one can hope for in those situations is to keep the interfaces as clean as possible, comment what you can, especially the corner cases, and wave a dead chicken over the whole thing. And that's perhaps where software breaks from engineering into art. =)

                                  When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                                  W 1 Reply Last reply
                                  0
                                  • D Daniel Pfeffer

                                    I find coding styles to be like handwriting. When you've read enough code written by others, you'll find that you can read any style - as long as the writers followed it consistently. Life is too short to refactor everything into your preferred style.

                                    Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                                    M Offline
                                    M Offline
                                    MarkTJohnson
                                    wrote on last edited by
                                    #24

                                    Daniel Pfeffer wrote:

                                    Life is too short to refactor everything into your preferred style.

                                    But, but those people over there are doing it WRONG!

                                    1 Reply Last reply
                                    0
                                    • H honey the codewitch

                                      all true, and yet the unsensible is perhaps underrated. some of the most inspirational bouts of coding I've had have left me with something I couldn't understand later. not that I appreciate that entirely. it is what it is. but yeah, I at least try to make the function names clean if it comes down to that. plus, have you ever noticed how sometimes, code as it matures can get a bunch of weird forks in its codepath to handle one-offs and bugs, sometimes in other systems its interacting with, and so the simplest, cleanest solution doesn't work in the real world. The truth is, I distrust all of this. It makes me uneasy. But it's a reality. The best one can hope for in those situations is to keep the interfaces as clean as possible, comment what you can, especially the corner cases, and wave a dead chicken over the whole thing. And that's perhaps where software breaks from engineering into art. =)

                                      When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                                      W Offline
                                      W Offline
                                      W Balboos GHB
                                      wrote on last edited by
                                      #25

                                      codewitch honey crisis wrote:

                                      some of the most inspirational bouts of coding I've had have left me with something I couldn't understand later.

                                      Let me tell you about a closely guarded secret: comments! Orders of magnitude more valuable than wasting mind and body on some OCD organization of symbol and function names. Rule-makers aren't sitting with you seeing the problems you need to solve. If you've ever built a database then you may have come to a time where normalization just isn't the best choice - you break it in a strategic spot for simplicity and efficient execution.   The basic rule of thumb: do it the best way you can.

                                      Ravings en masse^

                                      "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                                      "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                                      H 1 Reply Last reply
                                      0
                                      • K KarstenK

                                        I lived in a socialist society and thats my feeling about. Owning means of production is not really essential in socialism, because there arent any profits from it. It brings only responsibilities to maintenance it. X|

                                        Press F1 for help or google it. Greetings from Germany

                                        H Offline
                                        H Offline
                                        honey the codewitch
                                        wrote on last edited by
                                        #26

                                        that's the def of socialism but whatever. i'm not having this convo with you on a programming board. seriously.

                                        When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                                        K 1 Reply Last reply
                                        0
                                        • W W Balboos GHB

                                          codewitch honey crisis wrote:

                                          some of the most inspirational bouts of coding I've had have left me with something I couldn't understand later.

                                          Let me tell you about a closely guarded secret: comments! Orders of magnitude more valuable than wasting mind and body on some OCD organization of symbol and function names. Rule-makers aren't sitting with you seeing the problems you need to solve. If you've ever built a database then you may have come to a time where normalization just isn't the best choice - you break it in a strategic spot for simplicity and efficient execution.   The basic rule of thumb: do it the best way you can.

                                          Ravings en masse^

                                          "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                                          "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                                          H Offline
                                          H Offline
                                          honey the codewitch
                                          wrote on last edited by
                                          #27

                                          comments are cool, but have you ever implemented an algorithm before you understood it? how do you comment that effectively? for me, what happens is, I code it to learn it. Maybe over the course of weeks, months, even years, depending on what it is I'll refactor or even rewrite as I understand the problem domain better. As I do those refactors and rewrites I can and do add comments. Maybe it's because I think visually so my process to translate algo to code is weird or something, but I'm sure I can't be the only one who does this.

                                          When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.

                                          W 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