Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My application has an icon file which is stored in version control. Now tomorrow I might decide to change the icon. I'm debating between two possible naming conventions for the icon file:

  1. Keep the filename fixed, e.g., application.ico
  2. Have the filename reflect the nature of the image, e.g., happyface.ico

Option 1 doesn't say what the file is. It could give the illusion that two wildly different images are somehow different "versions" of the same thing. With option 2, I'd not only have to add a new file and delete the old one, I'd have to modify the resource file to reflect the new icon filename.

On a related but different angle:

A website with a header image. Is the filename header.jpg or sunrise-family-smiling.jpg?

Should image file names reflect their function in the application or their content? What would be a best practice for this?

share|improve this question
up vote 11 down vote accepted

Option 1 doesn't say what the file is. It could give the illusion that two wildly different images are somehow different "versions" of the same thing

Well, it is, isn't it? I know that it might have changed from a smiley face to a corporate logo, but it's still different versions of a specific icon in your application.

I think you're missing the point by focussing on subversion. The key deciding factor should be the application itself. When I'm adding the icon that appears in the title bar, I'm not thinking "I must describe the content of the image." I'm thinking "what is this image to the application, or to anyone else who needs to change it later?"

And therein lies a bigger point. When I come to change it later, do I really want to change the name of the image in the application? It's still doing the same thing, so why does the app need to know I've changed it?

share|improve this answer

Personally, I have always used a descriptive name for all my files, including icons, and even if it resource names have to be changed.

In your case, I would actually take a third choice:

  • If the application was called XYZZY, then I would name the icon for the application "XYZZY.ico". No matter what the icon looks like, it is the proper icon for the XYZZY application.

By extension, if I needed a couple of different sized icons, I would add the size of the icon to the name. So for a 48x48 icon, I would have "XYZZY_48x48.ico".

In relation to the last part "A website with a header image. Is the filename header.jpg or sunrise-family-smiling.jpg?": If the website is for Plugh Corp, then I would use "Plugh_Header.jpg".

share|improve this answer
+1 for icon size – SHug Oct 5 '11 at 20:46
Adding the name of the application to the filename is slightly redundant, as surely all the files will reside in a folder named XYZZY, and therefore the company can be determined from that. Do you name the home page XYZZY_index.htm? Then why do so for images? – Gavin Coates Oct 6 '11 at 8:43

I'd go for application.ico and header.jpg as it's simpler and nearer to the image meaning in your application.

You may want to store the images as happyface.ico and sunrise-family-smiling.jpg somewhere else (in another repo or maybe in the same) if you want to keep them easily accessible, too.

share|improve this answer
+1 for specific repo and general repo for images – SHug Oct 5 '11 at 20:46

Another thing to keep in mind: if this is a web application, you'll want to change the filename even if the image has not change fundamentally simply because that forces the users' browsers to load the new version rather than using the old one from cache.

From Yahoo's Best Practices for Speeding Up Your Website:

Keep in mind, if you use a far future Expires header you have to change the component's filename whenever the component changes. At Yahoo! we often make this step part of the build process: a version number is embedded in the component's filename, for example, yahoo_2.0.6.js.

share|improve this answer
+1 nice trick indeed. – Sardathrion Oct 6 '11 at 8:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.