Keep code base clean – avoid unnecessary variable assignments
Keep code base clean – avoid unnecessary variable assignments
Can’t tell you how frustrating it is to find the context of a variable stripped away by a meaningless re-assgiment (login required).
From Clean Code: A Handbook of Agile Software Craftsmanship:
The name of a variable, function, or class, should answer all the big questions. It
should tell you why it exists, what it does, and how it is used
| 123456 | // doing this totally strips away any meaningful context
$my_temp_variable
=
$employee_salaries
[
$an_employee_name
];
$gross_salary
=
$bonus_factor
*
$my_temp_variable
;
// hopefully the language constructs allow full variable interaction
$gross_salary
=
$bonus_factor
*
$employee_salaries
[
"Fred"
]
|
| — | — |
Advertisement
Author’s Note
Initial md
Generated using https://github.com/jsr6720/wordpress-html-scraper-to-md
Original Wordpress categories: [‘Clean Code’]
Original Wordpress tags: “Clean Code”, “clean code”, “temp variables”
Original Wordpress comments: None
Significant Revisions
tags: 2011, wordpress, txcowboycoder, clean-code, programming, technology
- May 6th, 2024 Converted to jekyll markdown format and copied to personal site
- Jul 14th, 2011 Originally published on txcowboycoder wordpress site