lundi 5 juillet 2021

Abridged - What design pattern should I use? Different classes, same static behaviour

tl;dr:

Hi guys, is there a design pattern I can use that:

  1. Could be equivalent to having static interfaces (which are impossible)

  2. Has to be used in a language that does not support multiple inheritance (C#)

  3. Is implemented by a lot of different classes for similar (but not identical) behaviour, that must be accessed statically (ie: formatting a string, which each class does a different way).

  4. May have several different behaviours per class, so Class A and B both have methods x() and y(), but Class C has x() and z().

Essentially, I want to have "static interfaces" for specific static methods that can exist in specific, different classes.

Original question (more in-depth, and I explain everything in more detail): What design pattern should I use? Different classes, same static behaviour

Aucun commentaire:

Enregistrer un commentaire