Yesterday I was trying to refactor some code which has lots of code duplication, static type casting between sub types and cohesive. After some refactoring I decided to use java’s strategy design pattern to remove code duplication and make it extendable. The motive behind using strategy pattern was to move behavior out of the...
The benefits of using an iterator is to allow the the client to iterate over the collection of objects, without exposing implementation details. This gives you the benefit to change what collection the Iterator iterates over and how each element is served, without making any change the client’s code. To iterate a custom collection,...