On the dimension of deterministic and random Cantor-like sets