Differentiation between COD (direct object) and COI (indirect object) can be tedious, but once you've understood the basic rules, things get a lot simpler!
Je mange une pomme - I’m eating an apple. Je is the subject, the person who is doing the action. Une pomme is the object because it is on the receiving end of the action.