We report a simulation study on competition between cracking and peeling, in a layer of clay on desiccation and how this is affected by the rate of drying, as well as the roughness of the substrate. The system is based on a simple 2-dimensional spring model. A vertical section through the layer with finite thickness is represented by a rectangular array of nodes connected by linear springs on a square lattice. The effect of reduction of the natural length of the springs, which mimics the drying is studied. Varying the strength of adhesion between sample and substrate and the rate of penetration of the drying front produces an interesting phase diagram, showing cross-over from peeling to cracking behavior. Changes in the number and width of cracks on varying the layer thickness is observed to reproduce experimental reports.