PDA

View Full Version : Do you use Pimpl Idiom?



ComaWhite
25th March 2009, 07:13
I was just curious. How many, and if some or anyone uses the pimpl idiom when writing in your own personal project or not.

Mods delete this if you think this is a stupid poll :p

jpn
25th March 2009, 07:33
Well, if the "personal project" happens to be a library project where it makes sense to use PIMPL due to binary compatibility requirements, then of course.

ComaWhite
25th March 2009, 08:09
Well I mean, like for person project where it's not like a library but an application itself.

ivan.cukic
25th March 2009, 08:47
Yes, even in personal projects. Mostly for things that I plan to make reusable (that is, the things that could eventually end up in a library :) )

jpujolf
25th March 2009, 09:13
Yes, I'm using it all along my code. In libraries ( for binary compatibility ).

And also in any program I've to made, to avoid "stupid recompilations" ( oops, I've added a private member to "that" base class & ALL the app gets recompilated... )

I think in general It's a good practice to put the less you can / need in header files and use pimpl.

wysota
25th March 2009, 09:48
I'm often using it in my projects in three cases:
1. I want good code separation
2. I'm implementing a library or a class that I think might become part of a library in future
3. I'm creating implicitly/explcitly shared data classes (where you have to use P-IMPL)

P-IMPL makes your code harder to read so it should be avoided where maintenance is a priority or where weaker programmers are involved.