Вопрос

I had a search but didn't find what I was looking for, please feel free to link me if this question has already being asked.

Earlier this month this post was made:

http://net.tutsplus.com/tutorials/php/why-youre-a-bad-php-programmer/

Basically to sum it up, you're a bad programmer if you don't write comments. My personal opinion is that code should be descriptive and mostly not require comment's unless the code cannot be self describing.

In the example given

// Get the extension off the image filename  
$pieces = explode('.', $image_name);  
$extension = array_pop($pieces);  

The author said this code should be given a comment, my personal opinion is the code should be a function call that is descriptive:

$extension = GetFileExtension($image_filename);

However in the comments someone actually made just that suggestion:

http://net.tutsplus.com/tutorials/php/why-youre-a-bad-php-programmer/comment-page-2/#comment-357130

The author responded by saying the commenter was "one of those people", i.e, a bad programmer.

What are everyone elses views on Self Describing Code vs Commenting Code?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
scroll top