How do you prevent constipation?

Avoid certain foods. There are certain foods that have a tendency to cause constipation. Dairy products and cheeses to name a few. Increasing fluid in the diet, increasing the amounts of fresh fruits, vegetables, and roughage in the diet all help. It can be done without medications or laxatives.
Stool softeners. I usually recommend a high fiber diet such as prune juice and/or stool softeners such as colace twice daily and/or MiraLAX (polyethylene glycol) daily work well.