Is there a rule for knowing when terms in algebraic fractions can be cancelled?

Terms can be cancelled if they are in factorised form.