What are your code pet-peeves?
-
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)
-
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)
Harvey Saayman wrote:
Wrong public void someMethod(){ //some code } Right public void someMethod() { //some code }
You don't like the Java brackets style, yet you like the Java camel notation... I think it's a matter of taste. Neither of the 3 examples are catastrophic. For samples 2 & 3 I actually prefer the 'Wrong' approach, because I find it easier to read.
-
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)
Do while true
Loop
That's one of the things I hate to see, and an ex-co worker off mine use to use them everywhere Now every time I have to alter his code (wich has been limited to one programme now) I go crazy, fortunatly doesn't happen much anymore.
-
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)
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) -
Harvey Saayman wrote:
Wrong public void someMethod(){ //some code } Right public void someMethod() { //some code }
You don't like the Java brackets style, yet you like the Java camel notation... I think it's a matter of taste. Neither of the 3 examples are catastrophic. For samples 2 & 3 I actually prefer the 'Wrong' approach, because I find it easier to read.
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)
-
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)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)
-
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)
-
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)
-
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)
-
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)
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.
-
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)
-
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)
IF( j - k ) 30,50,100
-
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)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
-
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)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.
-
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.
-
These days I prefer the automatic properties of c# 3 public string UserName { get; set; }
Same here, unless there's specific logic involved. Automatic properties save some coding. ;)
-
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)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.
-
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)
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.
-
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)
-
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)
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.