As a rough guide it works. As a hard and fast rule its rubbish.
For example I gould have a 100 gallon tank with only half a foot of surface area (exagerated situation but makes a point

). If I followed the rule I could have have 100" of fish in there. In reality the lack of surface area would mean you could only have a few fish in there.
The surface area is just as important as the water volume.
The next thing to consider is the actual size of the fish in relation to the tank and their habits. A large fast moving fish will need a lot of swim room (a 5ft tank for example) while an equally large slow moving fish might be fine with a tank that is only 2ft long. Just because a tank is 24g doesnt mean you could fit a 2ft fish in it

Also some fish need to have their own space (cichlids for example) and this needs to be taken into account also.
I pretty much use this system though still for most of my stocking.
I count:
1inch of a slim bodied fish (ie a cardinal tetra) as 1/2"
1 inch of think bodied fish (ie tiger barbs) as 1"
1 inch of messy/large bodied fish (ie plecos) as 1-2"
Also if I have a take with shoaling fish I would tend to overstock (depending on tank size, fish, etc) but I always overfilter my tanks and do weekly water changes.
So in short if you are new to fish keeping it is a good general guide. Once you know about the fish you are keeping though it can be adapted or ignored.