First of all deep apologies if this question is unclear, I did not know a better way to word it.
So, I am currently doing some light reading( Clean code by Robert C Martin), and I have stumbled upon something I do not get.
This quote was written by Ron Jeffries the author of Extreme Programming
"After years of doing this(coding) work it seems to me that all programs are made up of very similar elements. One example is 'finding things in a collection', We often find ourselves wanting a particular item from that collection, when i find that happening, I will often wrap the implementation in a more abstract method or class.
What does Jefferies mean by that bold section highlighted
Say, for example, you had a method that looks through a collection of Object X and returns one based on a key field.
Elsewhere in your code you have another method that looks through a collection of Object Y and returns one based on a key field.
Why not simply create a generic helper class that you can pass a collection of objects and a key field? You design this helper to be generic and applicable for both the cases above. You now have a useful utility that can be used again and again in your code.
Alternatively you could introduce an abstract base class to both Class X and Class Y. Now they both implement a 'search' method as defined in the abstract base class. The search call is now generic and can be used throughout your code. Find in a collection is now generic in your code.
The intention is to recognise repeated patters of behaviour and handle them with generic code.
This has several benefits: