An elementary approach to algebraic geometry codes