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. What are your code pet-peeves?

What are your code pet-peeves?

Scheduled Pinned Locked Moved The Lounge
csharpdatabasequestion
47 Posts 22 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 Harvey Saayman

    Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

    Wrong
    public void someMethod(){
    //some code
    }

    Right
    public void someMethod()
    {
    //some code
    }

    Wrong
    if (someCondition)
    someMethod;

    Right
    if (someCondition)
    {
    someMethod();
    }

    Wrong
    public bool Selected
    {
    get{return selected;} set{selected = value;}
    }

    Right
    public bool Selected
    {
    get
    {
    return selected;
    }
    set
    {
    selected = value;
    }
    }

    What do you hate seeing in code?

    Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

    you.suck = (you.passion != Programming)

    B Offline
    B Offline
    Brady Kelly
    wrote on last edited by
    #19

    public bool Selected { get; set; }

    ;P

    Daily WTF Memes

    1 Reply Last reply
    0
    • H Harvey Saayman

      blackjack2150 wrote:

      You don't like the Java brackets style, yet you like the Java camel notation...

      yeah, btw i didnt even know camel casting came from Java??

      blackjack2150 wrote:

      I think it's a matter of taste

      definitely a matter of taste, out of all 3 examples i HATE the java bracket style the most, i find it hard to read and irritating.

      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

      you.suck = (you.passion != Programming)

      B Offline
      B Offline
      Brady Kelly
      wrote on last edited by
      #20

      Likewise. Unfortunately it is the convention in all our JavaScript, and it really pisses my off looking up from a closing brace to find the function start, and not seeing the opening brace where is should be.

      Daily WTF Memes

      H 1 Reply Last reply
      0
      • B Brady Kelly

        Likewise. Unfortunately it is the convention in all our JavaScript, and it really pisses my off looking up from a closing brace to find the function start, and not seeing the opening brace where is should be.

        Daily WTF Memes

        H Offline
        H Offline
        Harvey Saayman
        wrote on last edited by
        #21

        agreed! its actually weird how furious i get for something so silly...

        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

        you.suck = (you.passion != Programming)

        P 1 Reply Last reply
        0
        • H Harvey Saayman

          Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

          Wrong
          public void someMethod(){
          //some code
          }

          Right
          public void someMethod()
          {
          //some code
          }

          Wrong
          if (someCondition)
          someMethod;

          Right
          if (someCondition)
          {
          someMethod();
          }

          Wrong
          public bool Selected
          {
          get{return selected;} set{selected = value;}
          }

          Right
          public bool Selected
          {
          get
          {
          return selected;
          }
          set
          {
          selected = value;
          }
          }

          What do you hate seeing in code?

          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

          you.suck = (you.passion != Programming)

          D Offline
          D Offline
          darkelv
          wrote on last edited by
          #22

          Harvey Saayman wrote:

          Wrong public bool Selected{get{return selected;} set{selected = value;}}

          Fixed. :)

          1 Reply Last reply
          0
          • H Harvey Saayman

            Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

            Wrong
            public void someMethod(){
            //some code
            }

            Right
            public void someMethod()
            {
            //some code
            }

            Wrong
            if (someCondition)
            someMethod;

            Right
            if (someCondition)
            {
            someMethod();
            }

            Wrong
            public bool Selected
            {
            get{return selected;} set{selected = value;}
            }

            Right
            public bool Selected
            {
            get
            {
            return selected;
            }
            set
            {
            selected = value;
            }
            }

            What do you hate seeing in code?

            Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

            you.suck = (you.passion != Programming)

            D Offline
            D Offline
            Dave Parker
            wrote on last edited by
            #23

            Harvey Saayman wrote:

            What do you hate seeing in code?

            Unnecessary line breaks Actually I do prefer having more things on one line in many cases so there's less scrolling up and down but matter of taste I suppose and there are always #regions anyway.

            L 1 Reply Last reply
            0
            • H Harvey Saayman

              Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

              Wrong
              public void someMethod(){
              //some code
              }

              Right
              public void someMethod()
              {
              //some code
              }

              Wrong
              if (someCondition)
              someMethod;

              Right
              if (someCondition)
              {
              someMethod();
              }

              Wrong
              public bool Selected
              {
              get{return selected;} set{selected = value;}
              }

              Right
              public bool Selected
              {
              get
              {
              return selected;
              }
              set
              {
              selected = value;
              }
              }

              What do you hate seeing in code?

              Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

              you.suck = (you.passion != Programming)

              A Offline
              A Offline
              Anthony Mushrow
              wrote on last edited by
              #24

              I don't think you'd like my code. I often use the bracket style in number 1 (mostly for loops or if statements) I'll always skip the brackets in an if statement if there's only one line and my get sets go like this: public thing stuff { get { return } set { value } } It just saves so much white space. Anyway, its only preference.

              My current favourite word is: Nipple!

              -SK Genius

              Game Programming articles start -here[^]-

              H 1 Reply Last reply
              0
              • A Anthony Mushrow

                I don't think you'd like my code. I often use the bracket style in number 1 (mostly for loops or if statements) I'll always skip the brackets in an if statement if there's only one line and my get sets go like this: public thing stuff { get { return } set { value } } It just saves so much white space. Anyway, its only preference.

                My current favourite word is: Nipple!

                -SK Genius

                Game Programming articles start -here[^]-

                H Offline
                H Offline
                Harvey Saayman
                wrote on last edited by
                #25

                SK Genius wrote:

                skip the brackets in an if statement if there's only one line

                isnt that considered bad practice?

                Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                you.suck = (you.passion != Programming)

                1 Reply Last reply
                0
                • H Harvey Saayman

                  Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

                  Wrong
                  public void someMethod(){
                  //some code
                  }

                  Right
                  public void someMethod()
                  {
                  //some code
                  }

                  Wrong
                  if (someCondition)
                  someMethod;

                  Right
                  if (someCondition)
                  {
                  someMethod();
                  }

                  Wrong
                  public bool Selected
                  {
                  get{return selected;} set{selected = value;}
                  }

                  Right
                  public bool Selected
                  {
                  get
                  {
                  return selected;
                  }
                  set
                  {
                  selected = value;
                  }
                  }

                  What do you hate seeing in code?

                  Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                  you.suck = (you.passion != Programming)

                  A Offline
                  A Offline
                  Anna Jayne Metcalfe
                  wrote on last edited by
                  #26

                  Harvey Saayman wrote:

                  What do you hate seeing in code?

                  That's a tough one, but as a start I'd say:

                  • C++ code in which the author didn't know (or didn't care) how to use const correctly.
                  • Untestable code with a high cyclomatic complexity[^]
                  • Untidy code (yes, I do Code Like A Girl[^]. That way, other people can maintain it). ;)

                  Anna :rose: Having a bad bug day? Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

                  H 1 Reply Last reply
                  0
                  • H Harvey Saayman

                    Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

                    Wrong
                    public void someMethod(){
                    //some code
                    }

                    Right
                    public void someMethod()
                    {
                    //some code
                    }

                    Wrong
                    if (someCondition)
                    someMethod;

                    Right
                    if (someCondition)
                    {
                    someMethod();
                    }

                    Wrong
                    public bool Selected
                    {
                    get{return selected;} set{selected = value;}
                    }

                    Right
                    public bool Selected
                    {
                    get
                    {
                    return selected;
                    }
                    set
                    {
                    selected = value;
                    }
                    }

                    What do you hate seeing in code?

                    Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                    you.suck = (you.passion != Programming)

                    M Offline
                    M Offline
                    Mark C Hagers
                    wrote on last edited by
                    #27

                    Wrong: if ( <some boolean expression> == true) { ... } should be: if ( <some boolean expression> ) { ... } I find it irritating because it's just needlessly adding another operation to the Boolean expression. Even though the compiler will probably optimize it out, it looks amateurish. Of course this is even worse: If (<some boolean expression> == true) { a = true; } else { a = false; } Should be: a = <some boolean expression>;

                    Mark C Hagers New Media Ventures Amersfoort, the Netherlands

                    H 1 Reply Last reply
                    0
                    • M Mark C Hagers

                      Wrong: if ( <some boolean expression> == true) { ... } should be: if ( <some boolean expression> ) { ... } I find it irritating because it's just needlessly adding another operation to the Boolean expression. Even though the compiler will probably optimize it out, it looks amateurish. Of course this is even worse: If (<some boolean expression> == true) { a = true; } else { a = false; } Should be: a = <some boolean expression>;

                      Mark C Hagers New Media Ventures Amersfoort, the Netherlands

                      H Offline
                      H Offline
                      Harvey Saayman
                      wrote on last edited by
                      #28

                      i totally agree, i mentioned your first example to another poster in this thread. Your 2nd example is definitely worse, typical junior code both of them, somehow i skipped that level :rolleyes:

                      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                      you.suck = (you.passion != Programming)

                      1 Reply Last reply
                      0
                      • D Dave Parker

                        Harvey Saayman wrote:

                        What do you hate seeing in code?

                        Unnecessary line breaks Actually I do prefer having more things on one line in many cases so there's less scrolling up and down but matter of taste I suppose and there are always #regions anyway.

                        L Offline
                        L Offline
                        leppie
                        wrote on last edited by
                        #29

                        Anything more than 2 is a waste, 1 or 2 depending, is acceptable to me :) (but I prefer them to be a line apart) Alternatively interpreted: I place line breaks after section of related code statements, like paragraphs, but only in C#, not Scheme :)

                        xacc.ide - now with TabsToSpaces support
                        IronScheme - 1.0 alpha 4a out now (29 May 2008)

                        1 Reply Last reply
                        0
                        • A Anna Jayne Metcalfe

                          Harvey Saayman wrote:

                          What do you hate seeing in code?

                          That's a tough one, but as a start I'd say:

                          • C++ code in which the author didn't know (or didn't care) how to use const correctly.
                          • Untestable code with a high cyclomatic complexity[^]
                          • Untidy code (yes, I do Code Like A Girl[^]. That way, other people can maintain it). ;)

                          Anna :rose: Having a bad bug day? Anna's Place | Tears and Laughter "If mushy peas are the food of the devil, the stotty cake is the frisbee of God"

                          H Offline
                          H Offline
                          Harvey Saayman
                          wrote on last edited by
                          #30

                          i can t comment on the C++ cause i cant / havnt coded in any other language than C# and tSQL

                          Anna-Jayne Metcalfe wrote:

                          Untestable code with a high cyclomatic complexity

                          i agree, but in my situation it is often imposible to get a lower cyclomatic complexity score cause of the flexibility required in the system im developing.

                          Anna-Jayne Metcalfe wrote:

                          Untidy code (yes, I do Code Like A Girl[^]. That way, other people can maintain it)

                          i try my best to "code like a girl", but again with the flexibility required in my current project its often an impossible task.

                          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                          you.suck = (you.passion != Programming)

                          1 Reply Last reply
                          0
                          • H Harvey Saayman

                            Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

                            Wrong
                            public void someMethod(){
                            //some code
                            }

                            Right
                            public void someMethod()
                            {
                            //some code
                            }

                            Wrong
                            if (someCondition)
                            someMethod;

                            Right
                            if (someCondition)
                            {
                            someMethod();
                            }

                            Wrong
                            public bool Selected
                            {
                            get{return selected;} set{selected = value;}
                            }

                            Right
                            public bool Selected
                            {
                            get
                            {
                            return selected;
                            }
                            set
                            {
                            selected = value;
                            }
                            }

                            What do you hate seeing in code?

                            Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                            you.suck = (you.passion != Programming)

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

                            "Never hate" -- PIEBALDconsult (Or I could quote Tom Lehrer) While I agree with your preferences, I don't consider it a matter of right and wrong and I don't get upset when I see code like that. As mentioned by others, a style should be consistent; inconsistent style shows lack of discipline. Having said that, other things I avoid: Unnecessary local variables. Multiple return statements. The lazy comment: // Use of other techniques and syntactic sugar whose only purpose is to reduce keystrokes.

                            E H 2 Replies Last reply
                            0
                            • H Harvey Saayman

                              Im very fussy when it comes to my code base, when i see things like the following it will ruin my day completely and p!$$ me off so badly I have to take a minute so that my head doesn't explode.

                              Wrong
                              public void someMethod(){
                              //some code
                              }

                              Right
                              public void someMethod()
                              {
                              //some code
                              }

                              Wrong
                              if (someCondition)
                              someMethod;

                              Right
                              if (someCondition)
                              {
                              someMethod();
                              }

                              Wrong
                              public bool Selected
                              {
                              get{return selected;} set{selected = value;}
                              }

                              Right
                              public bool Selected
                              {
                              get
                              {
                              return selected;
                              }
                              set
                              {
                              selected = value;
                              }
                              }

                              What do you hate seeing in code?

                              Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                              you.suck = (you.passion != Programming)

                              E Offline
                              E Offline
                              Ennis Ray Lynch Jr
                              wrote on last edited by
                              #32

                              Than logic. Many of your wrongs are perfectly acceptable. In fact I author all of my code with squirlies on the same line as a construct because I prefer that style ... and it is a style issue not a right or wrong. Developers, such as yourself, who have pet peeves that have nothing to do with bad programming waste a lot of code reviews that could be better spent. Any developer worth his or her salt should be able to read any consistently written code without any difficulty.

                              Need a C# Consultant? I'm available.
                              Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                              H P 2 Replies Last reply
                              0
                              • P Pete OHanlon

                                Actually - there's another pet peeve of mine. People using properties when a field would suffice. If the object is serializable then, fine, make it a property otherwise do you really need to have a property that does nothing other than assign a value?

                                Deja View - the feeling that you've seen this post before.

                                My blog | My articles

                                E Offline
                                E Offline
                                Ennis Ray Lynch Jr
                                wrote on last edited by
                                #33

                                Not doing so makes reflection a PITA. If MS would have made no distinction between a field and a property maybe I would agree. Of course, I don't like properties, instead I prefer set and get methods. Interesting that the CLR doesn't support properties. (I am going to stop there so others can stick their foot in their mouth when arguing against me)

                                Need a C# Consultant? I'm available.
                                Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                P 1 Reply Last reply
                                0
                                • P PIEBALDconsult

                                  "Never hate" -- PIEBALDconsult (Or I could quote Tom Lehrer) While I agree with your preferences, I don't consider it a matter of right and wrong and I don't get upset when I see code like that. As mentioned by others, a style should be consistent; inconsistent style shows lack of discipline. Having said that, other things I avoid: Unnecessary local variables. Multiple return statements. The lazy comment: // Use of other techniques and syntactic sugar whose only purpose is to reduce keystrokes.

                                  E Offline
                                  E Offline
                                  Ennis Ray Lynch Jr
                                  wrote on last edited by
                                  #34

                                  OMG, don't get me started on more than one return in a method. I used to throw things at people that did that. Erasers, hats, empty cups, bricks. No matter the ammunition it is hard to suggest to a developer that thinks a 500 line method is OK that more than one return is bad.

                                  Need a C# Consultant? I'm available.
                                  Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                  1 Reply Last reply
                                  0
                                  • E Ennis Ray Lynch Jr

                                    Than logic. Many of your wrongs are perfectly acceptable. In fact I author all of my code with squirlies on the same line as a construct because I prefer that style ... and it is a style issue not a right or wrong. Developers, such as yourself, who have pet peeves that have nothing to do with bad programming waste a lot of code reviews that could be better spent. Any developer worth his or her salt should be able to read any consistently written code without any difficulty.

                                    Need a C# Consultant? I'm available.
                                    Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                    H Offline
                                    H Offline
                                    Harvey Saayman
                                    wrote on last edited by
                                    #35

                                    i think you misunderstood what i was trying to say... i couldnt think opf better words to use so i used right and wrong. I didnt literally mean that the wrong examples are wrong as in theyll not compile or have performance implications.

                                    Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                                    you.suck = (you.passion != Programming)

                                    E 1 Reply Last reply
                                    0
                                    • P PIEBALDconsult

                                      "Never hate" -- PIEBALDconsult (Or I could quote Tom Lehrer) While I agree with your preferences, I don't consider it a matter of right and wrong and I don't get upset when I see code like that. As mentioned by others, a style should be consistent; inconsistent style shows lack of discipline. Having said that, other things I avoid: Unnecessary local variables. Multiple return statements. The lazy comment: // Use of other techniques and syntactic sugar whose only purpose is to reduce keystrokes.

                                      H Offline
                                      H Offline
                                      Harvey Saayman
                                      wrote on last edited by
                                      #36

                                      like i told ennis, i couldnt think of other words so i used right and wrong.

                                      Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                                      you.suck = (you.passion != Programming)

                                      1 Reply Last reply
                                      0
                                      • H Harvey Saayman

                                        i think you misunderstood what i was trying to say... i couldnt think opf better words to use so i used right and wrong. I didnt literally mean that the wrong examples are wrong as in theyll not compile or have performance implications.

                                        Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                                        you.suck = (you.passion != Programming)

                                        E Offline
                                        E Offline
                                        Ennis Ray Lynch Jr
                                        wrote on last edited by
                                        #37

                                        You would call it wrong. One of the skills that will take a developer far is the ability to see past little things like this. Keep in mind C# is not the only language and Java in particular is notorious for the other style. It is probably my fault as I am growing cynical in my old age. I am just tired of seeing people call themselves Senior Developers who barely even know one language and one trait that is systematic of these people is going ballistic over something that has no rational basis in the quality of code. Don't mature into that guy!

                                        Need a C# Consultant? I'm available.
                                        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                        H 1 Reply Last reply
                                        0
                                        • E Ennis Ray Lynch Jr

                                          You would call it wrong. One of the skills that will take a developer far is the ability to see past little things like this. Keep in mind C# is not the only language and Java in particular is notorious for the other style. It is probably my fault as I am growing cynical in my old age. I am just tired of seeing people call themselves Senior Developers who barely even know one language and one trait that is systematic of these people is going ballistic over something that has no rational basis in the quality of code. Don't mature into that guy!

                                          Need a C# Consultant? I'm available.
                                          Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

                                          H Offline
                                          H Offline
                                          Harvey Saayman
                                          wrote on last edited by
                                          #38

                                          i get that :) yes one day ill have to work on someone else's code one day but the project im working on now was designed and started by me so the dev's working on it will do it my way :-D

                                          Ennis Ray Lynch, Jr. wrote:

                                          tired of seeing people call themselves Senior Developers

                                          i didnt, not that i know of anyway... and i clam to be a junior dev right in my sig :)

                                          Harvey Saayman - South Africa Junior Developer .Net, C#, SQL

                                          you.suck = (you.passion != Programming)

                                          E 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