mercredi 23 août 2017

i have write a class which always delegate it's function parameter to on of it's member, how can i improve the code

how can i refactor this code, this kind of code structure really smells bad.

example code below:

class A {
public:
    void init(){
        // do something and init b
    }
    auto foo(auto p, auto q){
        return b.foo(p, q); 
    }
    auto bar(auto p, auto q){
        // maybe do something here
        return b.bar(p, q); 
    }
    // all kinds of funcs like foo and bar
private:
    B b;
}

is there any design pattern or best practice for this?

Aucun commentaire:

Enregistrer un commentaire