Understanding bar lines: A brief history
In Western notation, the vertical bar line through the musical staff first came into usage at a point in history when polyphonic textured music (two or more melodies simultaneously) evolved from monophonic textured music (one melody only; no accompaniment). The principal purpose of employing bar lines at that moment in time was to coordinate singers with one another, "to help align the voices and text," according to The New Grove Dictionary of Music and Musicians.
In modern usage, the bar line serves to divide the staff into measures and to indicate the first beat of each bar—in any meter, including mixed meter—by placing the bar line immediately before the bar's first beat. However, it was not always thus. For example, according to Grove, in the late Renaissance/early Baroque eras, in Altri canti di Marte from Monteverdi's eighth book of madrigals, the composer instead employed bar lines according to accent, as did Frescobaldi in one of his works, and as was also seen in several early operas.
Bar line custom and practice
As pointed out in The Essential Dictionary of Music Notation by Tom Gerou and Linda Lusk (Alfred Music):
1) The thickness of a single bar line is usually the same as, or slightly greater, than the thickness of staff lines.
2) A double bar line is employed to mark the end of a composition or movement, and should consist of a thin bar line followed by a thick bar line.
3) For composite meters, broken bar lines are occasionally employed in order to clarify the division of the meter.
4) A brace connects the two staves of a grand staff. The brace is always followed by a systemic bar line.
Enter your text here ...
6) Bar lines are employed to group staves of an instrument family in an orchestral score.
7) When a key signature changes within a composition, the new key signature should appear to the right of thin double bar lines.
8) When a key signature changes at the start of a new staff, an advance-warning key signature (sometimes known as courtesy key signature) should appear to the right of thin double bar lines at the end of the preceding staff.
9) When the time signature changes within a composition, the new time signature should appear to the right of a thin single bar line.
10) When the time signature changes but starts on the following staff, an advance-warning time signature (courtesy time signature) should appear to the right of the last bar line on the preceding staff.
11) For D.S. al Coda, D.C. al Coda, and D.S. al Fine, use thin double bar lines.
12) A thin/thick double bar line, or two thin bar lines, may be employed at a Fine. (Different music editors differ in opinion with respect to this practice.)
It is strongly advised that composers and arrangers adhere as much as possible to traditional notational rules and guidelines that are understood and practiced by the vast majority of the musical community, in order to more effectively achieve musical clarity. Following the above notational rules regarding bar lines will contribute to garnering the respect of the experienced music reader.