Joe*_*Fan 1 methods naming-conventions
对于一个向容器添加内容的方法来说,如果它尚未存在,那么它的名称是什么,即
void AddCustomerToList(CustomerList list, Customer customer)
Run Code Online (Sandbox Code Playgroud)
但是这个名称没有正确表达,如果它已经存在,它就不会被添加.什么是更好的名字?AddCustomerToListIfNotThereAlready?EnsureCustomerInList?
将CustomerList更改为CustomerSet,然后显而易见.
add(CustomerSet set, Customer customer);
Run Code Online (Sandbox Code Playgroud)