I was wondering which method would be correct in terms of performance and best practice.
I have an array of URLs, I am scraping the content of these pages. I have a separate class to handle the scraping.
Currently I pass the array list to the class, the class then loops through the array contents scraping the contents for each array. I believe this to be the best way.
The other way I was thinking of was looping through the array, and I would pass each URL to the class. This seems like it would be slower to me but I’m not sure.
If the two methods are both viable then what are their pro’s and con’s?
I would suggest you do what you believe is the clearest and simplest.
Passing the array might be marginally fastest and might save a few nano-seconds, but unless what you are doing is of the order of a few nano-seconds, it is highly unlikely you will be able to tell the difference.