in reply to Perl Best Practices - Loop Labels
Firstly, a huge thankyou to everyone who replied. I am somewhat overwhelmed by the volume of responses. It is very much appreciated.
After posting the OP yesterday, I replied to the first responses and then logged out. Logging back in today, I was presented with about a dozen direct replies; many of those had spawned their own little sub-threads. Much as I might like to reply to everyone, it really isn't practical; so, please take this as a general response to all. Another reason for a general reply is that I think I'd probably be repeating myself in many individual replies; this would tend to bloat the thread.
The extent to which people use labels varies quite a lot. Some use them always, which is in line with PBP; others use them to a greater of lesser degree depending on context, which aligns more with my usage; and, some either generally don't like them or have never found a need to use them. I expect, in general, I'll probably continue with my current usage; although, some replies were thought provoking and that may cause me to modify usage in certain situations.
Refactoring was mentioned in quite a few places and I agree with this. I inwardly groan whenever I encounter programs with monolithic tracts of code; these are hard to read, comprehend, maintain, extend and debug. I generally tend to have more _helper()-type functions than direct_interface()-type functions.
Another point raised was the depth of nesting and, again, I concur. Wherever possible, I generally try to avoid nesting at all; there are occasions when that's unavoidable, in which case I aim for shallower rather than deeper; if I've reached a fourth level, I've probably done something wrong and will rethink the solution.
A number of people spoke about PBP not being a set of rules that should be slavishly followed but rather a series of suggestions and recommendations to be adapted as appropriate. Definitely no argument from me on that one.
In conclusion, I asked for your thoughts and have received them in profusion. I won't be making any drastic changes to the way I work but I may modify some behaviours in a small way. Again, thank you very much.
— Ken
|
|---|