+ 20
Bad Programming Habits?
35 Answers
+ 71
Search for 'clean code' on Google. That will lead you to Uncle Bob. He wrote down, what dirty code is and how to avoid it. It's just too much to write it down here, but some of the most famous principles are:
- KISS (keep it simple, stupid)
- DRY (don't repeat yourself)
- MAYA (most advanced yet acceptable)
- convention over configuration
+ 46
- Using var instead of explicit data types.
- Using static instead of access modifiers like public/private.
- Using public for class data members.
- Placing a } on the same line as code.
- Not indenting your code.
- Placing multiple code statements on 1 line.
- Importing unneeded packages/files/classes.
- Poorly naming identifiers for variables, methods, and/or classes.
- Not being consistent with your conventions.
- Not following the language's conventions, and the conventions you follow yourself or for the place you work for.
- Not using comments.
- Stealing others' work without credit/permission.
- Providing poor prompts for user input.
The list goes on and on, but that's what I thought of off the top of my head. :3
+ 26
a progrmmer must know this sites:
stackoverflow.com
github.com
+ 19
not practicing much
+ 18
PYTHON!!!
if not import this:
print(dirty code)
+ 16
To be clear: luka is right somehow, because that question has been asked a lot of times before here at Q&A and I could easily find the other posts.
And it is never a good idea to be rude to someone only because he takes a different opinion. You don't have to agree, but please don't attack someone personally. We want to discuss here, not fight.
+ 13
worst programming habit is to write a code in such a way that even you can not understand it in future
+ 13
@Surya
Yes, readability is really important. But IDEs manage that.
+ 9
poor comment, poor naming
//this is a stream
function myFunc() {
//code
}
+ 9
There is something that i think it is essential, most of the time ppl tend to forget about it and we only regret it when we visit the code a few months later, which is comment the code. Specially the logic behind some lines of code, or the use of a tricky variable!
+ 8
TO GIVE UP
+ 8
Just 1-> Lack of practice... Trust me bro coding is fun and once it execute correctly, its the biggest happy and satisfying thing for the geek....
+ 7
this is not one of them it is a newb question but not retarted.
+ 7
Most people do not follow the indentation. Take this example:
void func()
{ if(...)
{cout<<"Example";
int a++;}
else(...){
int a--;
}}
The above example is not easy to understand at the very first glance but now look at this:
void func()
{
if(...)
{
cout<<"Example";
int a++;
}
else(...)
{
int a--;
}
}
This is how indentation helps. This makes the program more easier to understand, not just for you but to the others who see it.
But most of them fail to follow this.
+ 7
Reviewing your code after you write it for comments and optimal solution will result in clean and efficient code.I believe peer review can help a lot .
+ 6
@Tashi explained that it has been asked lots of time. In itself it is not a bad question.
+ 6
less practice
+ 6
not writing comments, so when you come back later you are confused.
+ 4
copy and paste
+ 4
1) Not including semicolons at the end of statements ( especially in JavaScript ).
2) Only learning new things and features but not practicing to have a command on what we know.
3) Using too many variables. This will take up the space of the system.
4) Not properly using the loops.