Good Variable Names
Re: Good Variable Names
I'll sometimes go one further, even
Re: Good Variable Names
Well that will clear up any confusion! Hehe.
Re: Good Variable Names
Comments at the end of blocks can be handy, but a better solution is to avoid large blocks as much as possible. Break up large, potentially confusing blocks of code into smaller, easier to handle functions. This helps promote code reuse as well reducing unnecessary code complexity.
Often, if I can identify an easily encapsulated bit of logic, especially within if statements or other forms of nesting, I break it out into a separate function to keep the original function clean and easy to read, regardless of an immediate reuse need.
Often, if I can identify an easily encapsulated bit of logic, especially within if statements or other forms of nesting, I break it out into a separate function to keep the original function clean and easy to read, regardless of an immediate reuse need.
Re: Good Variable Names
Yeah, to extend that, defining local functions within a large one is useful. For example, sometimes I'd have:
It is much easier to grok then when all the logical pieces within it are 'labelled'.