rapidpro / mailroom

Backend services for the RapidPro platform.
Other
25 stars 28 forks source link

Naming cleanup #61

Open nicpottier opened 5 years ago

nicpottier commented 5 years ago

I haven't been super consistent on the naming of all the utilities in models, need to do through and audit and rename them.

Current thinking is for extreme clarity, so things like, CreateContact should be InsertContact and things like GetContact should be SelectContact.. IE if we know for sure we are going to hit the DB, then we use Select .. if there may be a cache in between then we can use Get. Same rules for Update etc..

rowanseymour commented 3 years ago

Thought about this a bit when I was adding all the new import stuff. I think I would lean toward verbs that provide some information about the higher-level contract rather than the db operations, since there's often multiple db operations involved.

So exported functions that look like:

CreateX - create new X and return it, or error
GetX - return existing X or an error
GetOrCreateX - return existing or newly created X or an error
LookupX - X may or may not exist, may return nil and no error
UpdateX
ReleaseX

But those might call lower-level utilities which do actually describe their DB behavior:

queryX (e.g. queryContactIDs)
insertX (e.g. insertContactAndURNs)
deleteX