Yii Framework Forum: Sometimes hard to extend Yii - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Sometimes hard to extend Yii What's the reason for those private attributes? Rate Topic: -----

#1 User is offline   Y!! 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 978
  • Joined: 18-June 09

Posted 03 January 2010 - 04:41 AM

Again I run into problems extending Yii. This time I want to access CClientScript::$_metas in order to change meta tags into another pattern.

For example this meta tag

Quote

<meta content="en" name="language" />


should be transformed into

Quote

<meta name="language" content="en" />


qiang mentioned in one of my feature requests:

Quote

We usually only change private variables to protected or public per user request with
sufficient reasons. We may choose to refactor the code, instead, if that works better.


In this case I don't think at all it's a sufficient reason and also I don't think the way Yii generates the meta tags will be changed upon request (because it's already very short and clear code).

So my question is (as a OOP and framework beginner), what's the reason for all the private attributes that could be protected in order to make things more extendable? I know what I'm trying to accomplish in this case is very trivial and one may don't understand the need for it. But that's not the case, I think a framework should give the developer the freedom to extend everything IF it's easy possible to implement. A protected attribute is very easy so I don't get it.

Anyone? Maybe qiang himself? :D
0

#2 User is offline   Onman 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 175
  • Joined: 26-December 09
  • Location:The Netherlands

Posted 03 January 2010 - 09:39 AM

View PostY!!, on 03 January 2010 - 04:41 AM, said:

So my question is (as a OOP and framework beginner), what's the reason for all the private attributes that could be protected in order to make things more extendable? I know what I'm trying to accomplish in this case is very trivial and one may don't understand the need for it. But that's not the case, I think a framework should give the developer the freedom to extend everything IF it's easy possible to implement. A protected attribute is very easy so I don't get it.


The goal of OOP is to treat an object as a black box: you can make it behave a certain way, but it is not necesairy to know exactly how that behavior is accomplished.
In the case of your meta tag its behavior depends on the value of its properties (like 'language'). So as long as you can assign values to the language and other properties, it is not important how these are represented in the final html document.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users