hooks icon indicating copy to clipboard operation
hooks copied to clipboard

Custom methods must be protected

Open uilianries opened this issue 6 years ago • 2 comments

  • Any method declared as public, must be provided from ConanFile
  • Any custom method must be declared as protected
  • Any private method is not be accepted

closes #126

Wiki:

#KB-H036: "CUSTOM METHODS"

When a new method have to be added to the recipe, and it is not a default one provided by ConanFile, it must added as protected:

class Recipe(ConanFile):
    def configure(self): # default methods are public
        pass

    def _configure_cmake(self): # custom methods are protected
        pass

    def __private_routine(self): # private should not be used. Use protected instead.
	    pass

uilianries avatar Nov 01 '19 17:11 uilianries

@uilianries also, I wonder, why do we forbid to use private members? is it somehow bad/harmful?

SSE4 avatar Nov 07 '19 20:11 SSE4

@SSE4 private attributes are not bad, but how many times we needed them for a recipe? Maybe twice all this time, only for workarounds and helpers, which are not the regular flow.

uilianries avatar Nov 07 '19 20:11 uilianries