"When I built my addition, the building inspector made me tear out the bedroom window and put in a bigger one! Personally, I don't think it's any of his (deleted) business how big my bedroom window is!"

I hear these kinds of gripes from disgruntled do-it-yourselfers all the time. Not to rub salt in the wound, but in most such cases, a passing acquaintance with the building code - and even more important, an understanding of its intent - would have saved these folks a lot of frustration.

Though it may seem like it at times, building codes weren't formulated to harass do-it-yourselfers. In fact, they arose to protect public health and safety during the late 19th and early 20th centuries, a time when a population explosion in American cities was leading to ever more squalid and unsafe living conditions. This was an era in which tenement apartments variously lacked heating, natural light, access to fresh air or a means of escape in case of fire.

On a larger scale, poor separation between closely packed buildings meant that a small fire in one structure could quickly spread to adjoining ones. Too often, the result was raging urban conflagrations, such as the Great Baltimore Fire of 1904, which destroyed 1,500 buildings over 140 acres.

Even nominally fireproof masonry buildings - whose entire safety equipment might consist of a red-painted pail of water labeled FIRE placed on each floor - were far from invulnerable. Such buildings commonly housed overcrowded sweatshops with inadequate means of escape in emergencies, and, inevitably, there were a number of horrific fires.

The worst was New York City's Triangle Shirtwaist Fire of 1911, in which 146 garment workers, most of them immigrant girls and young women, either were overcome by the fire or leapt to their deaths from the building's ninth floor. The subsequent investigation determined that one exit on the ninth floor had been blocked by fire and that the other had been locked from the outside. The building's exterior fire escape, the last possible means of egress, was flimsily built and poorly attached. It collapsed when the panicked workers swarmed over it.

Building codes arose in an effort to prevent such needless tragedies from recurring. In one way or another, every code provision - including the one that raised that do-it-yourselfer's hackles - trace back to this source.

Ensuring an escape route in case of emergency is a primary function of building code provisions, and in residential buildings this usually means providing more than one way out in case the primary egress is blocked by fire. In a bedroom, that emergency escape route is the window.

Once we understand the code's intent, requirements that may seem arcane or burdensome suddenly make sense. Most are meant to ensure that buildings will stand up safely, that habitable spaces have at least minimal access to natural light and fresh air and that there's always a way out in case of emergency.

Next time, we'll look at a few basic building code requirements and what they're meant to accomplish.