loop once or loop multiple times
To keep this simple, I have a list of items and i have to do two tasks with this list. For efficiency one programmer is saying loop once and perform both tasks. The other programmer is saying make two different methods for each task for readability and maintainability, so you would actually be looping twice through the list. Which is the better practice? Thanks
Re: loop once or loop multiple times
Re: loop once or loop multiple times
No, we just did code review at work and this came up. Maybe this should be in the Object Oriented Forum?
Re: loop once or loop multiple times
Then go with the more senior/respected programmer's comment. If it were me, and I wrote your company's best practices/style guide, I'd document the second programmer's comments as company policy, but it's not me.