Bad Programming Habits? | Sololearn: Learn to code for FREE!


Bad Programming Habits?

3/7/2017 6:00:01 PM

Fake Mask

38 Answers

New Answer


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


- 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


a progrmmer must know this sites:


not practicing much


PYTHON!!! if not import this: print(dirty code)


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.


worst programming habit is to write a code in such a way that even you can not understand it in future


@Surya Yes, readability is really important. But IDEs manage that.


poor comment, poor naming //this is a stream function myFunc() { //code }


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!




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


this is not one of them it is a newb question but not retarted.


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.


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 .


@Tashi explained that it has been asked lots of time. In itself it is not a bad question.


less practice


not writing comments, so when you come back later you are confused.


copy and paste


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.