Here's a good rule of thumb: comments exist to explain WHY a piece of code exists rather than WHAT the code actually does. "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Newbies, in particular, tend to over-comment-describing things that don't need to be described and missing the point of what a "good comment" actually is. In fact, as soon as newbies are introduced to comments, they're pretty much encouraged to comment as often as they can.īut it almost feels like we've swung too far in the opposite direction. "Write good comments" is the oldest piece of advice in the world of programming. Related: The Best Free Online Coding Courses for Computer Programming ![]() Some languages, like Python and C#, have language-wide style guides that you may want to follow. And if you mix tabs and spaces, you deserve to have your keyboard taken away.ĭecide what you're going to do from the outset and stick with it through and through. If you use GetThisObject() in one place, don't go with FetchThatObject() somewhere else. If you're going to use camelCaseNaming for variables, don't adulterate it with underscore_naming. ![]() If you prefer tabs to spaces, don't let us convince you otherwise. If you want braces on their lines, go for it if you want to precede method calls with spaces, fine. We're not here to declare that one style is any better than another. We have nothing against good programming tutorials, but one of the downsides is that newbies end up picking a wide variety of conflicting habits, especially as they pertain to coding style.
0 Comments
Leave a Reply. |