You have comments and comments. Beginners especially like to translate each line of code into a "readable language."
// Assign "a" to x. $x = "a"; // Do stuff with x and get y. $y = do_stuff($x); // Return y. return $y;
While experts (bit), more experienced programmers often do:
// Do stuff with "a" and return it. $x = "a"; $y = do_stuff($x); return $y;
or even
// Do stuff with "a" and return it. return do_stuff("a");
Needless to say, the first example is "excessive commentary." However, those comments can also be posted as a comment function. Just write self-evident code, for example. do not use variables like $x , but give it a noun, such as $speed or so, and give the function a verb name, such as increment_speed() or so. Thus, you can simply leave all comments inside the function that are already explained by the code itself.
Over-commenting, however, does not adversely affect performance. Unless this is the number of lines of comments in one line of code, especially if it is an interpretation language. Compiled languages ββsuch as Java do not suffer from this; comments are already deleted after compilation.
Update : You have included sample code; it's really exaggerated to comment on private properties, especially if they already have a self-evident name. Function comments are in order.
Balusc
source share