function names - "standartised" prefixes

Posted by dnsmkl on Programmers See other posts from Programmers or by dnsmkl
Published on 2012-11-22T13:47:22Z Indexed on 2012/11/22 17:10 UTC
Read the original article Hit count: 227

Filed under:

Imagine you have such routines

/*just do X. Fail if any precondition is not met*/
doX()

/*take care of preconditions and then do X*/
takeCareOfPreconditionsCheckIfNeededAtAllAndThenDoX() 

A little bit more concrete example:

/*create directory. Most probably fail with error if any precondition is not met (folder already exists, parent does not exists)*/
createDirectory(path_name)

/*take care of preconditions (creates full path till folder if needed, checks if not exists yet) and then creates the directory*/
CheckIfNotExistsYet_CreateDirectory_andFullPathIfNeeded(path_name)

How do you name such routines, so it would be clear what does what?



I have come to some my own "convetion" like:

naiveCreateDirectory, ForceDirectoryExists, ...

But I imagine this is very standard situation.

Maybe there already exists some norms/convetions for this?

© Programmers or respective owner

Related posts about naming