Lift the nouns and the verb from the sentence. You need the nouns because both the subject and the object are nouns. Similarly, you need the verb to tell which noun is the subject and which noun is the object.
For example, if you are presented with a sentence that reads, "Bob baked a pie," the important words to focus on are the nouns "Bob" and "pie," plus the verb "baked."
Use the verb to figure out which noun is a subject and which noun is an object. Subjects are the nouns that are acting while objects are the nouns that are being acted upon.
For example, "Bob" in the above sentence is doing the baking, meaning that "Bob" is a subject. In contrast, the "pie" is the noun that is being baked, meaning that "pie" is an object.
Check to see if there is more than one subject and/or object. Although most sentences have only one subject and one object, some sentences can have more than one of either type of noun or even more than one of both types of noun.
Continuing from the above example, if the above sentence had been "Bob baked a pie and a cake," then "cake" would be a second object in the sentence. Similarly, if the sentence had read, "Bob and Roberta baked a cake," then "Roberta" would be a second subject in the sentence.
Separate nouns identified as objects as either direct or indirect objects. Direct objects are being directly impacted by the action undertaken in the verb while indirect objects are impacted only indirectly by that same action.
For example, if the sentence had read, "Bob baked a pie for Roberta," both "pie" and "Roberta" are considered objects because they are the nouns impacted by the verb. However, "Roberta" is considered an indirect object because "Roberta" is not being baked but instead is the recipient of the "pie" that is being baked.