There are two types of custody to be considered. First is residential custody; this is with whom the children will reside. Second is legal custody; this is who will have the authority to make decisions for the children.
Residential or physical custody is the right of a parent to have his or her children reside with them. Parents who are married presumably have their children live with them in a nuclear family. Upon the commencement of a divorce action and the impending, if not existing physical separation of the parties, the question of with whom the kids will live comes to the forefront. Parents are free to make an agreement as to with whom the children will live and what time they will spend with the other parent. This is the preferred method of resolving residential custodial arrangements.
Most any judge will tell parents that they are far better off and their children are far better off if they can work out the details of custody of their children between themselves and without the need for the court to get involved. No matter how well-meaning a judge is, he or she knows that they can never do as well by the children of a marriage as the parents can do for their children. Anytime a judge has to decide the residential or legal custody of children, the children lose.