Cracks and dislocation arrays in heterogeneous media