in reply to A question of style - declaring lexicals
I'm not sure that this is the most important consideration, but I've found that declaring variables as close to the scope as is required, what you call style #1, allows you to pull things out into subs more easily.
This is not only for refactoring, but also for simplifying code by reducing the indentation level. The use of good subroutine names and comments can make things more clear. I don't know, but I always feel that subroutine level comments are clearer.
I tend to use fairly descriptive variable names, making accidental reuse rare. It is a danger though, I agree.
Re^2: A question of style - declaring lexicals
by jordanh (Chaplain) on Jun 07, 2004 at 15:00 UTC
|
I'm not sure that this is the most important consideration, but I've found that declaring variables as close to the scope as is required, what you call style #1, allows you to pull things out into subs more easily.
This is not only for refactoring, but also for simplifying code by reducing the indentation level. The use of good subroutine names and comments can make things more clear. I don't know, but I always feel that subroutine level comments are clearer.
Update: After reading what tilly had to say, I realized that I'm actually advocating style #2, not #1. I hadn't read what you had to say closely enough!
Update II: How did this happen? I thought I was updating the parent, but I created a new node... oh well. | [reply] |
|