Actually Vic it was common opinion in the 70's that guns were superflous and were not included in many frigate/destroyer sized ships including the then latest type 22 'Broadsword' frigates. That theory was proven wrong in the Falklands where the guns were very useful indeed. Guns were then fitted as standard to these ships. I suspect that the demise of the gun remains much exaggerated and no, I do not believe that a gun is included just 'because the public likes to see one', but instead are included as they are important for the kind of low-intensity warefare that these ships can get involved in. Think for a moment, a big 4.5inch barrel pointing at a Somali pirate is a lot more intimidating than a missile unseen in its VL silo, it would make a very satisfying big warning splash alongside their boat too, can't be done with a missile.
Here is a drawing of it.
1 Flight deck to take Lynx or Merlin combat helicopter
2 Navigation radar
3 Long-range radar monitors air and surface threats
4 Communications mast
5 Small-calibre gun
6 Multi-function radar can guide ship's missiles and detect enemy ones
7 Gunfire control system
8 Vertical-launching system for short- and long-range missiles
9 Medium-calibre main gun
10 Bow sonar (under keel)