当前位置:网站首页>Functions should not specify operation types through variables

Functions should not specify operation types through variables

2022-06-25 08:00:00 Channing Lewis

To reduce code repeatability , I wrote a general function , Various similar operations are implemented by specifying parameters .

But my colleagues suggested that I should encapsulate a separate interface for each parameter even in this way , Because the name of the specified parameter may change , If you want to change it, you should change every place where you call this function , Or I need to convert the parameter name inside the function again .

This does not take into account the parameter name changes , The old parameter name is used by another operation , If you don't change it, you can't tell whether to execute the old operation or the new operation .

So a generic interface should only be used internally , External or need a separate interface .

原网站

版权声明
本文为[Channing Lewis]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250627176308.html