Given a virtually simulated tablet which launches apps like FooApp and BarApp which inherit from class App, what would be a good way to tell a function LaunchApp(...) which app to launch?
I'm currently passing LaunchApp(System.Type appType), where appType is e.g. typeof(FooApp), which then gets validated within the function. However, this pattern seems to lack proper type safety and passing autocompletion comfort. An alternative pattern on the other hand, where I use an Enum which then gets converted to the appType via e.g. switch-case, doesn't seem to adhere to D.R.Y. as I need to keep another redundant appType enum list. What would be a good pattern here?
Aucun commentaire:
Enregistrer un commentaire