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.
  • L leppie

    For the property, I would accept the get and set on each own line, if the property setter/getter was only 1 line long. Eg:

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

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

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

    ya i can handle that :) but ive seen even some articles here that have one line getter and setter like in my "wrong" example and it completely puts me off reading the rest of the article / code.

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

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

    J 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)

      E Offline
      E Offline
      ed welch
      wrote on last edited by
      #7

      redundant code, for example: void SetValue(const int value);

      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)

        E Offline
        E Offline
        eyeseetee
        wrote on last edited by
        #8

        1. Constantly declaring lots of local strings 2. Bad naming conventions i.e tbtestbox1, tbtextbox2 etc

        1 Reply Last reply
        0
        • H Harvey Saayman

          ya i can handle that :) but ive seen even some articles here that have one line getter and setter like in my "wrong" example and it completely puts me off reading the rest of the article / code.

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

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

          J Offline
          J Offline
          Jacquers
          wrote on last edited by
          #9

          These days I prefer the automatic properties of c# 3 public string UserName { get; set; }

          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)

            N Offline
            N Offline
            Nagy Vilmos
            wrote on last edited by
            #10

            Style is very important. But within the context of a corporate development environment the actual style adopted is not important. What gets my goat[^] is when code is inconsistent. There are aspects of our code style where I work that I personally do not like, but I defend them. I feel I have to as it was arrived at by consensus. With thirty odd people working on my code base it is really easy to review code when it adheres to the agreed guideline. Without even reading the code you can /see/ if it is okay.


            Panic, Chaos, Destruction. My work here is done.

            1 Reply Last reply
            0
            • E ed welch

              redundant code, for example: void SetValue(const int value);

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

              amen to that... or how about

              if (someBooleanValue == true)
              {
              //some code
              }

              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)

                R Offline
                R Offline
                Robert Surtees
                wrote on last edited by
                #12

                IF( j - k ) 30,50,100

                1 Reply Last reply
                0
                • L leppie

                  For the property, I would accept the get and set on each own line, if the property setter/getter was only 1 line long. Eg:

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

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

                  M Offline
                  M Offline
                  Mustafa Ismail Mustafa
                  wrote on last edited by
                  #13

                  That's exactly how I do it and is the cause of many an argument between me and other devs.

                  Don't forget to vote if the response was helpful


                  Sig history "dad" Ishmail-Samuel Mustafa "There's no point questioning the actions of a c0ck-juggling thunderc*nt" From the book of testy commentary by martin_hughes Unix is a Four Letter Word, and Vi is a Two Letter Abbreviation

                  1 Reply Last reply
                  0
                  • L leppie

                    For the property, I would accept the get and set on each own line, if the property setter/getter was only 1 line long. Eg:

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

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

                    P Offline
                    P Offline
                    Pete OHanlon
                    wrote on last edited by
                    #14

                    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

                    L E P 3 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

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

                      Not only serialization (well XML only, binary is fine with fields), but binding requires properties.

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

                      P 1 Reply Last reply
                      0
                      • J Jacquers

                        These days I prefer the automatic properties of c# 3 public string UserName { get; set; }

                        P Offline
                        P Offline
                        Pawel Krakowiak
                        wrote on last edited by
                        #16

                        Same here, unless there's specific logic involved. Automatic properties save some coding. ;)

                        P 1 Reply Last reply
                        0
                        • L leppie

                          Not only serialization (well XML only, binary is fine with fields), but binding requires properties.

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

                          P Offline
                          P Offline
                          Pete OHanlon
                          wrote on last edited by
                          #17

                          leppie wrote:

                          but binding requires properties.

                          It does, but my point still stands - do you really need to have a property that does nothing other than assign a value? BTW - binding is best performed if you implement the INotifyPropertyChanged interface, and the property then does more than just setting a value.

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

                          My blog | My articles

                          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)

                            V Offline
                            V Offline
                            Vikram A Punathambekar
                            wrote on last edited by
                            #18

                            I agree with #1 and #2, but I do #3 like Leppie says.

                            Cheers, Vıkram.


                            "if abusing me makes you a credible then i better give u the chance which didnt get in real" - Adnan Siddiqi.

                            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)

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