Formation of double compact objects