For the file: nothing.
The file will be treated in exactly the same way.
If you try to open the file with a program then there can be a difference depending on the program.
E.g. if I use somepictureViewer picture
then there are three things which can happen:
- The program will look inside the file to determine it type. This is why many files start with something called MagicNumbers. (e.g. a JPEG file will usually start with JFIF in the first bytes. A .gif file with
GIF87
or GIF89
. A PDF with PDF13
, etc etc. This is the clean, neat way.
- The program will try to open the file and assume it is the default format. This might leads to some messed up contents if it guesses wrong.
- The program will look at its extension and assume that a specific extension belongs to a specific file format. This can work out great and this can produce horrible results.
The most obvious example in this is with windows, where I can open a file called demo.xls
and the default settings make the assumption that a file ending in .xls is an excel file. If it is, then things work great. If it happens to be a misnamed picture (and yes, I have seen this in the wild with clueless users trying to get a picture inside an excell sheet) then things will simply go wrong.
But for the file itself: Nothing changes.
and can you please answer the ..what do I gain part of the question ? – Suhail Gupta – 2013-01-08T17:25:54.460
Depending on the OS: Either nothing or automatic opening with a specific program. (Read: if you use windows you can set it to automatically open all programs with an extension of your choice with a chosen program). – Hennes – 2013-01-08T17:31:16.630
as an application developer what do I gain ? – Suhail Gupta – 2013-01-08T17:35:19.540
Nothing at all since the file stays precisely the same. – Hennes – 2013-01-08T17:39:02.527
1@SuhailGupta To Hennes' point, as an application developer, you can be confident that your file is not going to be opened in Notepad on your end user's system by default, and help keep it from being inadvertently deleted. So, in the opposite, by naming it .db, you gain having it NOT open with a specific program by default. A filename and extension can convey a file's intended purpose or relationship with other files. – maxwellb – 2013-01-08T18:42:09.140
@SuhailGupta: Agree with whatever maxwellb said, although if you don't want your users messing with your program's data files easily, use a binary format instead of a text-based one. – Karan – 2013-01-08T19:22:54.867