design patterns - C++ where I'll need local extension or foreign method? -
i'm not familiar c++ enough know 2 similar refactorings (introduce local extension , introduce foreign method) needed. know cases forces use those, can't figure sample classes need "trick". i'm making c++ refactoring tutorial, new developers, looks need yours :)
if used it, please tell me in , why. in advance.
"foreign" methods methods operate on, aren't members of class. in java, means (static) methods of other classes take first class argument. in c++, you'll need aware of free functions. unlike java , in c++ methods can exist outside classes. int main() famous one. stl packed free functions. have peek in alone.
for java, site linked advises "foreign methods work-around" , suggest "introduce local extension" alternative refactoring. in c++, free functions not work-around. means there's less pressure introduce local extensions.
furthermore, in c++ functions not virtual default, , objects passed value. means "introduce local extensions" technique fails.
i hope goes show fundamental problem approach: you're taking refactoring techniques java, address specific java weaknesses, , try convert them c++ has rather different set of weaknesses. works, it's unnecessary.
Comments
Post a Comment