Local variables are generally preferred over global variables in programming due to their benefits in code maintainability, readability, and encapsulation. Using local variables reduces complexity and makes it easier to modify code without affecting other parts of the program. While there are specific scenarios where global variables may be necessary, such as in multithreaded applications or embedded systems, they are often viewed as a risk for introducing bugs. Encapsulation is emphasized as a best practice, promoting the idea that data should be hidden and accessed through methods rather than directly. Overall, the consensus is that local variables enhance program quality and should be prioritized in design.