mardi 6 août 2019

Design Pattern for when certain operations needs to be done on all the derived types

Let's say we have the following type hierarchy:

public abstract class Base {}
public class A : Base {}
public class B : Base {}

I need to perform the same operations on all the derived types from Base. As the first attempt, I tried to use generics here which sounds like not to be the best option.

I was wondering if there is a design pattern that suits this scenario?

Aucun commentaire:

Enregistrer un commentaire