dimanche 11 juin 2023

How to avoid conditional statements in Factory?

Imagine we have interface Button{ void Click(); } and its implementations: AndroidButton and IOSButton. Is it possible to create appropriate button based on input like string os = "ios" without violating the sOlid ? Like when a new type of 'os' appeared, we would not have to change the existing code

Aucun commentaire:

Enregistrer un commentaire