As a fresh programmer, one of the first thing for me to learn was to learn language and its syntax. Now my next training issue is to design my code heirarchy in such a way it is simple to maintain over time. One example I just encountered is below. It is in VBA for Excel but the concept extends to other languages too.
As someone with very little experience, it seems to me that the 2nd option is much clearer and I should use that style. However, I know sometimes that to a beginner programmer what seems like a relatively benign choice can end up hurting their development in the long run.
Are either of these two styles the better? I am not talking about personal 'stylistic' choices, I am talking about which one leads to more problems down the line, likely through over-complicating things.
For ws in Worksheets
remove duplicates
append remaining data to separate workbook
Next ws
versus
For ws in Worksheets
remove duplicates
Next ws
For ws in Worksheets
append remaining data to separate workbook
Next ws
Thankyou!
EDIT: By the way, it is not important if the less-readable design style is faster. A small increase in performance is not worth a loss of readability for my purposes at the moment.