I've been stumbling on this question and decided to post my very first answer on code review.
I started out with some obvious improvements that could be made straight away for the code posted in the OP.
Later I added some additional advice, how the code could be made more generic.
At this time I'm asking, there are two more answers that have gone straight away, to either provide
I have upvoted both of these, because I think they certainly provide value on the topic asked, but I'm just not so sure what's considered valuable at this site.
As I'm new here (kinda), how far should we get with such abstractions and deviate from the original code?