Use the Pimpl Idiom to Reduce Compilation Time and Enhance Encapsulation
Changes in the implementation details of a single infrastructure class don't have to trigger a wholesale recompilation of the numerous classes referring to the modified class. Find out how applying the Pimpl idiom can help you reduce compilation time and enhance encapsulation.
by Danny Kalev
May 12, 2005
ong compilation time is an issue of concern for many large-scale C++ projects. In some cases, a typical build cycle takes up a whole night or an entire weekend. This problem is aggravated by the fact that changes in the implementation details of a single infrastructure class trigger a wholesale recompilation of numerous classes that refer to the modified class. This solution will show you how to apply the Pimpl idiom to reduce compile-time dependencies, and thus reduce compilation time. Another benefit of using this technique is a higher level of encapsulation.
How can you avoid a wholesale recompilation when a change in the implementation details of a frequently-used class has taken place?
Use the Pimpl idiom, also known as the compiler-firewall idiom.