The naming tradition went as follows
First son after his paternal grandfather
Second son after his maternal grandfather
Third son after his father
Subsequent sons after other relatives, friends, neighbours, minister, doctor, schoolmaster, landowner etc
First daughter after her maternal grandmother
Second daughter after her paternal grandmother
Third daughter after her mother
Subsequent daughters after other relatives, friends, neighbours, wives of minister, doctor, schoolmaster, landowner etc
Middle names were more the exception that the rule until about the middle of the 19th century, but when bestowed they often adhered to the above tradition. Also quite a few people acquired in later life middle names which didn't feature on their baptism record or birth certificate!