-
Notifications
You must be signed in to change notification settings - Fork 0
Iterator design pattern
Devrath edited this page May 23, 2021
·
3 revisions
- We use the
Iterator
design pattern to iterate a collection of objects. - If we have used android or java and have tried looping the collection of items, We have seen this pattern before.
- Consider a module where we have a collection of objects that has to be iterated and retrieved.
- Many clients are using this module to get the items from this module.
- Now suppose we have a certain strategy that we have implemented for iteration of the client, now in the future we will modify the iteration strategy of the module with a new algorithm.
- If both are coupled, changes need to be made in all the clients that use the module.
- But using the
iterator design pattern
we can solve this. - only change need to be in the module and none in the clients that depend on that module.
Projects |
---|
BrowseHistory |
.