I have a class, which requires testing of some of its internal functions.
I do not want to embed these tests as part of the class, because they should be used only by some external entity whose sole purpose is system verification.
My solution to this comes in the form of declaring those internal functions protected
, and add a class which "exposes" them for external usage.
Here is a very simple (pseudo-code) example:
class public MyClass {
protected int add(int val1, int val2) {
return val1 + val2;
}
protected int mul(int val1, int val2) {
return val1 * val2;
}
}
class MyClassExposurer : public MyClass {
public int add(int val1, int val2) {
return super.add(val1, val2);
}
public int mul(int val1, int val2) {
return super.mul(val1, val2);
}
}
Is there a known terminology for this design pattern?
Thank you.
Aucun commentaire:
Enregistrer un commentaire