一种方法的好名字,如果在容器中没有铅的话,该方法会添加到容器中 [英] good name for a method that adds to a container if not aleady there

查看:52
本文介绍了一种方法的好名字,如果在容器中没有铅的话,该方法会添加到容器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果没有将某种东西添加到容器中的方法的好名,即

What's a good name for a method that adds something to a container if it's not already there, i.e.

void AddCustomerToList(CustomerList list, Customer customer)

,但是该名称不能正确传达该名称(如果尚未添加的话)不会被添加.什么叫更好的名字? AddCustomerToListIfNotThere是否已经存在?确保CustomerInList?

but that name does not properly convey that it won't be added if it's not there already. What is a better name? AddCustomerToListIfNotThereAlready? EnsureCustomerInList?

推荐答案

AddIfNotPresent

AddIfNotPresent

这篇关于一种方法的好名字,如果在容器中没有铅的话,该方法会添加到容器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆