Work

Introduce PImpl Refactoring for the CDT-Eclipse Plugin

Year: 2009
Type: dissertation
Abstract: CDT is a plug-in for the Eclipse IDE to write programs in C and C++. Eclipse offers refactorings, functions that restructure the code without changing its functionality. We implemented the Introduce PImpl Idom refactoring for C++. In C++ classes are usually divided in header files holding the declarations and source files holding the actual member function implementations. From the outside just public members are usable, but private members are also declared in the header file which has to be included to use the class. Introducing a new private member or modifying the signature of an existing leads to a change in the header and therefore forces all using classes to recompile. This is not a problem in a smaller project, but can have a great impact in larger projects that might take hours to recompile The PImpl Idiom describes a way to avoid that. The idea is to introduce a new implementation class within the source file that holds all member functions. The original class is reduced to public members presenting a stable interface and a private pointer to an instance of the new class (the pointer to implementation = PImpl). Those public members use the pointer to delegate all calls to the corresponding member in the implementation class. Because this class is only known within the source file, changes to it do not require classes using the original class to re-compile. But not only the re-compilation time drops, extracting the implementation in a separate class allows to use the original class as stable binary API and to hide the implementation in a library. With our refactoring all these advantages are just one click away.
Language: English
Open Access status: green
OpenAlex ID: W55946320
Cites: 1
Cited by:
Related to: 10