I was just curious about which idiom you prefer or use very often.. and why?
Please vote on the poll! I understand that there are a lot of choices but you can vote for multiples, but try to pick only the ones you think are the best, or most useful, or most elegant to use, i.e., the ones you value most and/or recommend the most.
- Resource Allocation Is Initialization
- Factory Functions
- PImpl (Cheshire Cat)
- Lazy construction or evaluation
- Type Traits
- Smart Pointers
- Curiously Recurring Template Pattern
- The Visitor Pattern
You can also post comments on why you feel a particular idiom is more important than another. And suggest any other idioms that you like if I didn't include them in the list.
I don't want this thread to turn into a huge debate on which idiom is _the_ best one (which doesn't make much sense because they all serve different purposes). But I rather would like people to share what they value most in terms of design objectives and how certain idioms or design patterns serve those objectives better than others. I understand also that I have included both OOP idioms and generic programming idioms, feel free to discuss both.
I hope people will participate.
To get the ball rolling, I should first say that it is incredibly hard for me to find the best in my opinion from the list. Also, some of them I have never used before and some I use all the time.
The PImpl idiom and Factory functions are for me very useful because I have found them to be the ultimate duo for cross-module programming and Application Binary Interfaces (ABI). The former is the well-known compilation firewall and the latter is very useful to control how and where objects get created. But I wouldn't rank either as number one because they don't pertain to all applications and don't necessarily bring much added value in terms of object-oriented programming.
Non-copyable is simple and very useful, and I find that it does add value to an OO design. But still, I would say not significant enough to make it to the top.
It is very hard to choose between Smart Pointers and RAII. They both are an invaluable part of "memory management made easy". But I would have to go with RAII just for the shear elegance of the resulting code. I think it pulled us away from the awful C-style programs filled with HANDLEs and void*.
What is your opinion?