Like Goth mall rats, plant eating dinosaurs sported lots of crests and spikes , but no one can be sure what good it did. Work in last month's Paleobiology takes a look at the stegosaur family. Their bony plates have been variously proposed to have been used as defensive weapons or heat exchangers, but they are actually poorly built for either purpose, being hollow (not good defense) and lined with apparently blind-ended blood vessels (not good for heat exchange). Support for these two ideas got even weaker in this work, when scientists considered the stegosaur ancestors. The ancestral plates lay very close to the skin and would not exchange heat at all, and were already hollow, arguing against an armor function.
The scientists propose that only use that makes sense is that these structures were for display, possibly for conspecifics to recognize each other. A reservation about this is that these things took a lot of energy to make. It's hard to believe that they were only an identifier. Couldn't they have worked out a secret handshake? For example, ants do it with odor.
There are lots of examples, including some very expensive ones, of males peacocking it up for sexual advantage; but stegosaur plates were similar between males and females.
Still, kooky exteriors are so widely seen in dinosaurs-- from the ceratopsians (spiky frills) to the hadrosaurs (head crests)-- so maybe species recognition was harder for them to accomplish than most.
UPDATE, June 14: Sort of an aside, but the turtle's shell seems to result from co-opting of the genes responsible for the arrangement of the ribs in other animals.