A quantum chemical investigation of the stability of compounds with identical formulas was carried out on 23 classes of compounds made of C, N, P, O and S atoms as core structures and halogens H, F, Cl, Br and I as substituents. All possible structures were generated and investigated by quantum mechanical methods. The prevalence of a formula in which its Z configuration, gauche conformation or meta isomer is the most stable form is calculated and discussed. Quantitative and qualitative models to explain the stability of the 23 classes of halogenated compounds were also proposed.