Why "private" scope?

Hi all!

I’ve been using Yii as my second framework for a couple of years and I like it. But I have annoying question: why, why you guys use private scope in framework classes instead of protected?! It’s craziness, it makes terrible extending of the base functionality, I have to copy your base classes to extend their functionality, not to simply extend them. Is there any explanation of this?



© Fabien Potencier - Pragmatism over Theory: Protected vs Private - here are some thoughts on the subject

Hah, I just wanted to mention that article too. But actually in Yii classes there are no “too many” private methods, at least I didn’t face any big problems extending core classes. And I agree making everything public/protected can make more problems for developers, because there are no guarantees these methods won’t change in the future.

More thoughts on the subject: http://en.wikipedia.org/wiki/Composition_over_inheritance

Thank you guys! It’s right and usefull thoughts, but there is code like

public function getViewPath($checkTheme=false)




		return self::$_viewPaths[$className];



		if($checkTheme && ($theme=Yii::app()->getTheme())!==null)



			if(strpos($className,'\\')!==false) // namespaced class





				return self::$_viewPaths[$className]=$path;


		$class=new ReflectionClass($className);

		return self::$_viewPaths[$className]=dirname($class->getFileName()).DIRECTORY_SEPARATOR.'views';



Directory name is hardcoded here, to use another directory name (not ‘views’) I should rewrite method in child class, but there are private properties… Yes, I can simply replace ‘view’ in result, but this is not good idea. Can you change my opinion?

Yeah, but Yii has many private properties… That’s a major issue in my practice, because for example you can’t just copy-paste method if it use private properties, or extend it… Or whatever you need…

I think just really low-level things should be encapsulated. All other should be protected. Of course some methods could be changed, but could be not. If developer call inherit protected method - he should know about the risk.