samedi 26 décembre 2020

Possible flaw in Iterator pattern?

Considering the following UML diagram: Iterator Pattern Image

If we add a method to addFriend() in Facebook class to add a new friend to a profile, the new friend doesn't reflect in the Facebook Iterator, and even if have a polling method in Facebook Iterator to check if any new friend has been added it would be a question of frequency and there can always be a corner case where the newly added friend didn't reflect.

I guess we can use Observer Pattern here but that would, in a way, imply that Iterator Pattern must always be used in conjunction with Observer Pattern.

I wanted to know if anyone thinks this is a legit issue, and how someone would go about tackling this

Aucun commentaire:

Enregistrer un commentaire