A Better Naming Convention?

I can’t decide the right way to go about this. I like the first set of my function names with “list” because they are easy to find, but when I get into things like wanting to edit a file it might be, editFile, so editFile and listFiles are far apart name-wise (I sort them alphabetically).

Should the subject/noun go first? Or should the Action go first? Any opinions on the most intelligent way to organize this? I find myself mismatching them time to time and I need to be more strict.

Example 1 
=================
countProjects
countFiles
listCategories
listFiles
listProjects
listUsers
listMessages
createMessage
editMessage
editFile
deleteFile

Example 2
=================
projectsCount
projectsList
projectsUsersList
projectMessagesList
filesCount
filesEdit
filesDelete
usersList

I personally prefer the second one, I’d rather see project operations all clumped together and file operations all clumped together. That way when you’re working on projects, all of the methods/functions are all together.

If each is a separate global function I would go with the second. If they are methods within a class or functions in a designated namespace the first.

I organize my model layer similar to the below. The methods include entity references when a single model manages more than one entity. So in the case of the users model it will only manage users. However, in the case of taxonomy two separate entities vocabularies and terms are managed. Thus, taxonomy methods reference the entity which they operate on generally to differentiate similar tasks such as fetching by id, listing, saving, etc.


class DAOUser {

	public function listAll() { }
	public function fetchById();
	
}

class DAOTaxonomy {

	public function listAllVocabularies() { }
	public function listAllTerms() { }
	public function fetchTermById() { }
	public function fetchVocabularyById() { }

}

Thanks dudes, I went with the 2nd one… And I decided to use Code Collapse by default – this made reading things MUCH MUCH nicer