简体   繁体   中英

Meaningful method name which create a resource when the one is not exist

I'm searching for an alternative name for a method which create a resource when the one is not exist. Previously I used long names like "createAddressWhenNotExist" or "createAccountIfNotExist".

What do you think about "ensureAddress" or "ensureAccount"? If you find this name in code will you understand it?

I think the naming method/ function is not fully represent the actual process.

You must declare the function description in that function with comment.

And I think createAddrIfNotExist or createAccountIfNotExist are the good names.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM