Phase and anti-phase boundaries in binary discrete systems: a variational viewpoint