How to force yourself to follow naming and other conventions

I believe that I program well, at least my code gives results ...

But I feel like I have a flaw ... I hardly follow any naming conventions ... not for variables, not for methods ... not for classes ... not for tables, columns, SP ... Further this, I almost do not comment on anything during programming ...

I always think that, let me see the results first, and then I come and fix the var names and other things later ... (Thanks to visual studio rendering here) ... But later doesn't come ...

So I need advice to get myself to accept the practice of the following naming conventions and comment ...

Edit: I totally understand the bad consequences of my practice, and I also know it's bad ... My question is how to force myself to follow discipline ...

+2


source to share


8 answers


Can you ask others about viewing the code? Or even try pair programming? Both of them can really help you do what you know you really need to do.



Also, depending on your language / platform, there may well be lint-like tools you can run to test that your code works.

+10


source


Hopefully you will spend a few years developing code written by someone else that has the same bad coding techniques you have. Only then will you really understand how bad your code really is. The code that "works" is minimal, coding, so it's easy to maintain, extend, and maintain, where the genius of a good programmer is.



+3


source


My gut tells me that your code is probably not as good as you think unless you have standards. You just have to choose something and stick to it. Being messy in your coding style probably means that you are wrong in logic, which probably means that you have a lot of errors and unexpected results in your code that will be difficult to deduce later. Good luck.

+1


source


Just remember the general coding rules you need to follow. And when you write code, write as recommended with appropriate conventions for variable and method names and have function headers. Don't worry about whether your code will work or not and the code is as recommended.
Comments can be added later, but naming conventions must be respected even in the proof of concept. Write your code with confidence that it will work.

Ask your code to view your peers and also you can use Fxcop to get static code.

+1


source


Best of all, your code should work and should do what it should. This is what you get paid for.

However, if it is unreadable, it will disappear because over time you will not remember what it does. To avoid this, edit and write down your code as soon as it works. As a general rule, you do not have to satisfy your work before it is properly documented. For every method you write, it doesn't take too long. But the longer you wait, the more time it will take to figure out what your code should do.

I know it's best to document before recording, but that won't work with cowboy coders . Another way can be a good alternative, as readable and well-documented code demonstrates developer skills.

+1


source


This is a matter of coding discipline. If you want to prototype something and then throw away the code, that's fine. However, the moment you need to reuse or debug your code, you will not regret not having comments and incorrect method / variable names.

As long as you work with the code, you know what it does. In a few months to a year, you will not remember everything so clearly. Then you probably won't regret not commenting out your code and choosing good names.

Consider also, if someone else had to read your code, how easy would it be to understand?

0


source


Running something like StyleCop (if you're writing C #) can go this route. It won't warn you about everything, but you can use it to make sure your methods have documentation comments etc.

However, as others have said, coding discipline is something that should come from within, not without.

0


source


If you want to change something about yourself, you need to motivate yourself to change it. This is one of the "rules of life".

This is not really what stack overflow can help you. I suppose a good suggestion to create motivation is to find a developer job and see how far your development habits go ...

-Carlos Nunez

0


source







All Articles