There are at least 5 types of BadCode:
1. Code that does not do what it is intended to do.
2. Code that does not perform as fast as it could.
3. Code that is not easily understandable.
4. Code that does not pick the Right Tool for the Job.
Where is it specified what the code is intended to do?
1. Code with explicitly Intention Revealing Names. This requires a high level of abstraction to be useful.
2. In Unit Tests.
3. In Acceptance Tests.
4. In my head. This is not a Good Thing.
5. In a functional specification. This is not a Good Thing either, if there are no corresponding Unit Tests or Acceptance Tests.
Bad Code Can Be Written In Any Language because we code in our heads, not in our machines – Programming Is in the Mind. Therefore, bad code is caused by bad thinking, and we can think badly regardless of our tools or the means of expression. No language can actually guide the programmer’s thinking to the point that only good code can be produced. At best, such a language would lose most of its generality. More likely, restricting the language to eliminate bad code is probably equivalent to (or perhaps even more difficult than) proving a program’s correctness. Perhaps it is even equivalent to solving the Halting Problem. I don’t know. I certainly do not expect any such capability to ever be available.
There are so many such good resources from developer/coder point of view in the following link, do have a look.