+ 5
What do you think is the worst and most common programming practice?
Common and Wrong Programming Practice
4 Antworten
+ 12
@Jakob Marley totally agree!
Naming conventions and coding conventions are really important concepts that saves your life!
For example call a bool "isSomething" or call a function using a verb "doSomething".
I read somewhere that if you have trouble naming a class, function, variable properly, probably your code or design maybe be bad or wrong.
+ 7
People don't know how to properly name variables, and as far as I can tell, have put very little study into the common conventions that are used in the industry. Not only is it annoying to read their code and try to figure out what they're intending to do, but it's also creating a lot of bad habits that'll come back to bit you in the butt. If you end up working for a company/team, that won't be tolerated. As well, imagine that you haven't touched the code in a year and then have to come back to change something, you'll have to decipher your own code because you didn't go about it properly.
EXAMPLE:
int j = 0;
int i = 0;
String s = "";
int age = 0;
int money = 0;
String name = "";
As you can see, when you properly name variables, it's very clear what their intended use is and what they'll be used for throughout your code. In the first example, it's so vague that it gives absolutely no value toward the variables purpose and if you were reading it for the first time, you'd have to do a lot of unnecessary work mapping out the variables used.
The exception is when dealing with loop counter variables. That's one of the very few places where it's appropriate to utilize single letter variables.
To go along with conventions, properly format your code. lol Nothing worse than having someone ask for help and all of their code is bundled up with zero concern over how it's formatted. Sure, the compiler will run it, but what about all the poor bastards that have to read your code? It's a nightmare and often I won't help if I have to take time to format it just so I can read it.
+ 5
Well in my opinion worst practice is to learn the code theoretical and not to try write it alone.. The best practice can be to write solo projects which implements all the things you want to learn..
+ 1
Avoid "using namespace std"
This won't hurt u now, but in the future when u are part of a big project it can cause problems.
If you’re putting the using statement into the header file, you’re aggravating the problem because the conflicts you will run into sooner or later will be in a module far, far away for no apparent reason until you find out that three layers down, one include file happens to include the file that contains the using directive and suddenly polluted
whichever namespace the file contained with the whole contents of namespace std.