jeudi 31 décembre 2015

OOP implementation details in C++

Speaking from an Object-Oriented point of view. What are some good guidelines about hiding implementation details from the reader? To go in further depth, three things that were clearly on my mind were

  1. Where would using opaque pointers and incomplete types be a good idea?
  2. Should I hide static member variables and give them file scope (in the implementation file) instead?
  3. Is it wise to only include the public interface as much as possible in a header file for a class and hide all the implementation details as much as possible with the help of opaque pointers?

NOTE : I am not looking to implementing interfaces in the context of inheritance. But rather an virtual base class free design. I personally don't like having virtual base classes where they are not needed. And the use case I have in mind is of a class which should not be extended but rather simply used to provide some sort of focused functionality. I hope that was not too vague :(

I know the above question is asking for personal opinion, if the members of the SO community feel like it should not be here. I would gladly take it down. But if someone wants to have a discussion then I would be open to any sorts of suggestions! Thanks!

Aucun commentaire:

Enregistrer un commentaire