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)
-
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.
-
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.
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)
-
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:
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.
-
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 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
-
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
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)
-
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:
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"
- C++ code in which the author didn't know (or didn't care) how to use