Today my buddy Steven Grant was running into some issue with a site he inherited from another ExpressionEngine developer. He was looking for what appeared to be a custom field but actually turned out to be a Snippet. This brought him to tweet the following:
please, please, please name your custom fields, global vars, snippets, low vars etc appropriately #eecms
— Steven Grant (@stevieg_83) September 16, 2013
Several years ago Leevi Graham started the discussion on Naming Conventions in ExpressionEngine at the San Francisco EECI Conference (2010). I remember sitting through his talk and thinking "This is all so obvious, but I've failed to implement it". I think we are all guilty of letting loose of standards at times. Perhaps you don't group your CSS as well as you usually do or you don't comment your Javascript or whatever. OK, maybe you don't but I know I need to be reminded occasionally.
But, I think you will find the following fairly low barrier as far as implementing goes. Let's start with some assumptions. You have a Field Group for a Channel. The Channel is called Staff. The Field Group is called Staff. You have 2 fields (let's keep this simple). The first is a WYGWAM field for Bio. The second is a Matrix field (or Grid) for images. The Matrix field has 2 columns. The first is a File field for the picture. The second is a Text field for Alt.
So in this instance, if memory serves correctly, we would have the following:
The Bio field would be given a long name of Bio and a short name of cf_staff_bio. This tells you that it is a custom field (cf), that it belongs to the Staff channel (staff), and that it is the Bio field (bio).
The images fields gets a long name of Images and a short name of cf_staff_images for all of the same reasons above. Where it delineates slightly is for the Matrix columns. In theory the File field would get a long name of Image File and the Text field would be Alt Text. The short name for Image File would be mf_staff_image_file and the short name for Alt Text would be mf_staff_alt_text. The difference here is that we are using mf for Matrix Field followed by the channel name and then the long name of the field.
Other fields that may be used would be Snippet (sn or snip), or Global Variables (gv).
The specific long name is not terribly important. It is the format that is important. Prepending tells any developer in our community the type of field that you were using and where to find it if they need to make adjustments.
Much thanks goes to Leevi for bringing this up several years ago. I just felt it needed repeating as it is not necessarily something that new folks to our community have heard.
If you have any additional suggestions leave a comment or touch base with me on Twitter
Edit: Apparently Steven wrote a blog post on this topic in 2010 as well.