I'm trying to improve my code by applying SOLID principles and I don't know what to prioritize, SRP or performance.
The problem involves fetching data from two different sources and then persisting that information in database. This leads me to the next flow:
- One class to fetch everything from an RSS. This fetching returns an array with the items of the RSS URI. Then I loop through each item and I create a simple array of POPOs.
- Then again I loop this array of POPOs to add additional data which comes from an API call.
- Finally I've to persist this data. Which may lead (or not if I build a insert multiple) to another loop as I'm using Eloquent which uses Active Record.
The main problem I find with this approach is that I separate concerns at the cost of worse performance (multiple loops). Something that I could solve executing all operations on the first loop.
Some people told me that it's ok as far as performance is not a problem, and is a trade-off that I should accept to keep my code maintenable, but is this the right approach?