They can be handy, but they'll dull quicker and can get caught, where as guns just shoot and go. Though the ammo can go. Both have their ups and downs.
Plus, guns can jam, misfire, etc. Best to have multiple guns. I have two rifles sitting behind me. Though the single shot wouldn't do too much good... At least the bullets for them are plentiful and cheap.
While I think a sword/katana would be fine for a trained person, a gun would be much easier to learn for the average jane/joe. I'm wanting to learn archery, with various bows, because it'd be nice to know how to shoot a bow accurately, in addition to a gun.
A hatchet is way way better than a katana. I hate how many people seem to think that a katana is a good weapon, even if you're trained on it. A hatchet will go through the skull with one swing, every time. It's small enough not to easily get caught on walls or anything of the sort, and also so that you can swing it repeatedly both quickly and in a small space. Yes, there's no finesse with a hatchet, good thing you're fighting enemies with no finesse to match.
Of course, ultimately a gun is the best weapon, but ammo runs out so a melee weapon is necessary. The argument that a gun attracts zombies is valid. But you should shoot and keep moving. The idea is, you're stuck somewhere behind a wall of zombies, you can shoot your way through and get away. You're not supposed to stick around and wait for those within ear shot to come to you.