I am currently reading the text Clean Code and came across an interesting excerpt:
After years of doing this work, it seems to me that all programs are made up of verysimilar elements. One example is “find things in a collection.” Whether we have a database of employee records, or a hash map of keys and values, or an array of items of somekind, we often find ourselves wanting a particular item from that collection. When I findthat happening, I will often wrap the particular implementation in a more abstract methodor class. That gives me a couple of interesting advantages.
I can implement the functionality now with something simple, say a hash map, butsince now all the references to that search are covered by my little abstraction, I canchange the implementation any time I want. I can go forward quickly while preserving myability to change later.
In addition, the collection abstraction often calls my attention to what’s “really”going on, and keeps me from running down the path of implementing arbitrary collectionbehavior when all I really need is a few fairly simple ways of finding what I want.
I thought this was useful, and want to try and see an example of this in action. So I was hoping someone could provide an example in the answers to demonstrate what is being said in the passage. Would this be appropriate to ask?