I sometimes come across, mostly when working with old code, the situation that one class acts as a mere forwarding of the calls to another class. Imagine there is a old controller which controls somethings however some of those can be dedicated to a new class. Now, the old controller will call the new class interface.
Ex.
class Controller
{
public:
void addObject(const std::string& id, const Object* obj)
{
m_Wrk->addObject(id, obj);
}
private:
Worker m_Wrk;
};
class Worker
{
public:
void addObject(const std::string& id, const Object* obj)
{
//do actual adding
}
};
Now, when thinking about testing the software, the interfaces might need to be tested in both classes, and it is harder in the controller as it does not mostly as it is necessary to check worker changes on controller tests.
Is this usage particularly bad or is it okay to use this kind of design in an already existing code as explained above.
Thanks
Aucun commentaire:
Enregistrer un commentaire