lundi 8 janvier 2018

Are there any advantages of using visitor design pattern over type extensions in Swift?

Visitor design pattern helps adding an operation to be performed on the objects of different classes without changing these classes. But it's not a very intuitive solution, especially because of necessity of double dispatch.

As a Swift developer I like to use type extensions in separate file for this purpose. Am I loosing something important? Are there any situations where visitor design pattern is the right choice?

Aucun commentaire:

Enregistrer un commentaire