Answer the question
In order to leave comments, you need to log in
What to sacrifice, DRY or self-documenting code?
Goodnight.
There is an application, recently finished refactoring. There are many classes, namespaces and even more functions, including single-line ones. I tried to make the code self-documenting, so you can often see functions like:
private function is_map_have_passed_param($map, $param) {
return is_array($map) && isset($map[$param]);
}
private function get_array_of_default_values_from($string) {
return explode('-', $string);
}
Answer the question
In order to leave comments, you need to log in
For this, comments have always been used . Until one day someone created a sect of self-documenters who worship the god of self-documentation and sacrifice everything to him, down to the fundamental principles of programming (DRY).
$x = is_array($map) && isset($map[$param]) /* is map have passed param */
$y = explode('-', $defaults) /* get defaults int range */
if (!empty($map[$param])) { // здесь комментарий для тех, кто не знает что такое empty()
}
$default_values = explode('-', $string);
(There is no need for a comment here, this line is already well "documented" thanks to the variable name.) Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question