Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I see that some software have the version number included as a part of their file name, while others do not. I am more used to the latter type, and I think that is more popular, but I see the former type sometimes in javascript libraries. For example, jQuery's file name is like jquery-2.1.0.js instead of jquery.js. Whenever I update these types of files, I have to look for the places in other programs that load these files, and change the file name they refer to, and manually delete the older version of these libraries. That is inconvenient to me, so I rather rename the file to exclude the version number, and keep the file name referred to to not include the version number.

I suspect that these numbers are for some kind of version control, but am not clear when and how they are used.

  • What are the pros and cons for including version numbers in the file name?
  • Is there de facto consensus on which areas of software or languages use version number in the file name, and which areas/languages do not? If so, is there any rationare for that?
share|improve this question
3  
biggest advantage is that you can ensure breaking changes don't happen before you are ready for them –  ratchet freak Mar 12 at 11:08
    
@ratchetfreak You don't update when you are not ready. Do you? –  sawa Mar 12 at 11:22
2  
@sawa Suppose jQuery.com/jquery.js is the URL of the latest version and that's what your code refers to. What would happen if jQuery would publish a radical update? Of course, you'd link to your own local copy but I think this is what ratchet freak means –  11684 Mar 12 at 16:08
    
@11684 I see, I got it. –  sawa Mar 12 at 16:37
1  
I would point out, in the example of jquery, that both the Google and cdnjs.com CDN hosted versions put the version in the directory tree, rather than the file name. (The jquery CDN from jquery.com and Microsoft both have the version in the file name.) –  Brian S Mar 12 at 18:06

2 Answers 2

up vote 22 down vote accepted
  1. It makes sense to specify the version you require. Behavior you may rely on could have changed, so newer is not always better. First, test whether a new version of a library works for you. Then, update explicitly.

  2. In the case of web resources, having the version be part of the filename is important in the context of caching. For static resources like jquery.js you will want a very long cache time before it's re-fetched. However, during an update you want your code to use the new version immediately, rather than having clients switch over to the new version during the next day or so. As foo-1.2.3.js is a different resource as foo-1.2.4.js, no caches will get in the way.

share|improve this answer
7  
+1 for mentioning the caching aspect. –  pllee Mar 12 at 15:20
1  
+1, though I think this answer is a little bit single-edged. There are indeed situations where "no version number" may be the better choice. See my answer below. –  Doc Brown Mar 12 at 16:13

(Excluding the situation of web caching mentioned by @amon): I assume you make a local copy of a third-party library for your program's use, otherwise the need for a version number would be obvious. The usage scenario of such a third party library within the software system you are developing may be one of these two:

  • all of the parts of your program which are using the lib shall always share the same version of the lib (ideally "the newest"), and you are going to update the lib from time to time. Then keeping the version number as part of the file name can be really tedious, and I actually would recommend to strip the number from your local copy of the file if possible. Notice that this is only a good a idea if you have confidence that the third party vendor keeps the lib mostly downward-compatible to earlier versions.

  • you expect to have some parts of your program which need version A, and some others which need version B. Then you will obviously need a version number for the third party lib. Note that this situation can also occur when you cannot easily test all of your software parts using the lib at once after introducing a new version.

And if you are a library vendor yourself, you should include the version number by default, but let the user of that lib decide for himself if he keeps that number or strips it away.

share|improve this answer
    
Yes. You are right. I was mentioning the first of your two cases. –  sawa Mar 12 at 16:02
1  
@sawa: note that your example was jquery, for which amon's web caching argument holds. The reasoning behind my answer was to explain different situations where "no version number" might be the better choice. –  Doc Brown Mar 12 at 16:11

Your Answer

 
discard

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.