Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Private methods and properties?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  Messages 1 - 25 of 27 - Collapse all  -  Translate all to Translated (View all originals)   Newer >
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post will appear after it is approved by moderators
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Martin Hasoň  
View profile  
 More options Mar 9 2011, 2:29 am
From: Martin Hasoň <martin.ha...@gmail.com>
Date: Tue, 8 Mar 2011 23:29:30 -0800 (PST)
Local: Wed, Mar 9 2011 2:29 am
Subject: Private methods and properties?

Hi,
In recent commits has been moved most protected methods and properties to
private. I think it's completely unnecessary step. In PHP I dislike the
keywords private and final (I hate their implementation in PHP). Why?
Private methods prevent reuse of code and keyword final kills reuse of code.
Real private methods do'nt exist in Python and Ruby (it is possible to callprivate methods or
overload them). In my opinion, framework should have almost no private methods.
I don't want to use the class composition for every little thing.

My tip: how to change value of private property in PHP 5.3 > ?

class A {
    private $a;

    public function __construct() {
        $this->a = new Foo(); //only one poorly designed place in class
    }

}

class B extends A {
    public function __construct() {
        $reflection = new ReflectionProperty('A', 'a');
        $reflection->setAccessible(true);
        $reflection->setValue($this, new FooBar());
    }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Henrik Bjornskov  
View profile  
 More options Mar 9 2011, 3:17 am
From: Henrik Bjornskov <y...@iamhenrik.se>
Date: Wed, 9 Mar 2011 00:17:47 -0800 (PST)
Local: Wed, Mar 9 2011 3:17 am
Subject: Re: Private methods and properties?

Yes please move them back.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Schaefer  
View profile  
 More options Mar 9 2011, 3:33 am
From: Christian Schaefer <cae...@gmail.com>
Date: Wed, 9 Mar 2011 00:33:44 -0800 (PST)
Local: Wed, Mar 9 2011 3:33 am
Subject: Re: Private methods and properties?

Hi,

there is a simple reasoning for making as much as possible private and
there was a lengthy discussion.

the reasoning goes something like this:

public and protected methods and properties are accessible for
developers using the framework. their code becomes dependant on that
interface.
to avoid breaking BC these accessible methods and properties can not
be changed for future releases.

private methods however can be changed as no code other than framework
code can use them.

so the more public/protected the symfony interface gets the more api
code needs to be maintained and is in fact set in stone.

the current approach is to make as much as possible private but to
reopen some of the code upon request when there is a good reasoning.

cheers
/christian

On 9 Mrz., 08:29, Martin Hasoň <martin.ha...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Henrik Bjornskov  
View profile  
 More options Mar 9 2011, 4:16 am
From: Henrik Bjornskov <y...@iamhenrik.se>
Date: Wed, 9 Mar 2011 01:16:26 -0800 (PST)
Local: Wed, Mar 9 2011 4:16 am
Subject: Re: Private methods and properties?

This is essentially killing inheritance for thoose classes. This means that
the framework can only be extended in the ways that core devs want. So if i
wanted to readd the request format magic for my projects i wouldnt be able
to do that.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukas Kahwe Smith  
View profile  
 More options Mar 9 2011, 4:47 am
From: Lukas Kahwe Smith <m...@pooteeweet.org>
Date: Wed, 9 Mar 2011 10:47:58 +0100
Local: Wed, Mar 9 2011 4:47 am
Subject: Re: [symfony-devs] Re: Private methods and properties?

On 09.03.2011, at 10:16, Henrik Bjornskov wrote:

> This is essentially killing inheritance for thoose classes. This means that the framework can only be extended in the ways that core devs want. So if i wanted to readd the request format magic for my projects i wouldnt be able to do that.

Its a question of maintainability. We want to provide a reliable API. By making everything protected we basically have to maintain a very large API. Worse yet, the user has no clue what extension points we recommend and which we do not. The end result is that you quickly cannot change anything anymore in the core, since users will use various different extension points to achieve the same.

Now in the past I have also been violently opposed to the above practice. However, these days we have several benefits:
- git makes it easy to fork
- git makes it easy for others to contributes patches to open up API's in specific places
- even if for some reason the patch is not accepted, with git its easier to keep your custom fork in sync

The other alternative is breaking BC in minor releases (aka 2.1) so I think going to private by default is the better approach. Again on a case by case basis we will then open up the API for inheritance.

regards,
Lukas Kahwe Smith
m...@pooteeweet.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gediminas Morkevicius  
View profile  
 More options Mar 9 2011, 5:03 am
From: Gediminas Morkevicius <gediminas.morkevic...@gmail.com>
Date: Wed, 9 Mar 2011 11:03:03 +0100
Local: Wed, Mar 9 2011 5:03 am
Subject: Re: [symfony-devs] Re: Private methods and properties?

+1 for private properties
letting do anything for a user will make a mess, dependency injection gives
you enough power allready

On Wed, Mar 9, 2011 at 10:47 AM, Lukas Kahwe Smith <m...@pooteeweet.org>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Hasoň  
View profile  
 More options Mar 9 2011, 5:42 am
From: Martin Hasoň <martin.ha...@gmail.com>
Date: Wed, 9 Mar 2011 02:42:24 -0800 (PST)
Local: Wed, Mar 9 2011 5:42 am
Subject: Re: [symfony-devs] Re: Private methods and properties?

For API is only public visibility (see
http://api.symfony-reloaded.org/master/). Protected visibility is for all
others. Private visibility is only for very very special method. Public
visiblity is for user, protected visibility is for programmer and private
visibility is for black box. For example framework Django doesn't have a
private method.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bulat Shakirzyanov  
View profile  
 More options Mar 9 2011, 5:19 pm
From: Bulat Shakirzyanov <mallluh...@gmail.com>
Date: Wed, 9 Mar 2011 17:19:55 -0500
Local: Wed, Mar 9 2011 5:19 pm
Subject: Re: [symfony-devs] Re: Private methods and properties?

This change is for the best.

For people that disagree, read up on
http://en.wikipedia.org/wiki/Open/closed_principle
<http://en.wikipedia.org/wiki/Open/closed_principle>
<http://en.wikipedia.org/wiki/Open/closed_principle>Allowing all properties
and methods to be hijacked in subclasses and allowing subclass anything
opens the system to modification, as any of the core system behavior can be
changed.
The correct approach is to provide contracts for extension (interfaces) and
concrete closed implementations that are well-tested and work, and can be
changed internally at any time, without breaking user-land code that
interacts with them (think refactoring).

If user-land code relies on some internal behavior however, the whole system
is much more error prone with any change to the core class, as it ripples
through all of its descendants.

My advice to all framework users is to provide alternative implementations
of pre-defined interfaces, instead than relying on overloading of core
classes.
Same applies to mocking - mock interfaces and not actual implementations.

Final and private are underused in PHP, which is the result of programmers
not thinking of providing explicit ways to extend their framework. Instead
of defining extension points, they simply leave the whole framework open to
modification, which leads to unexpected behavior. The fact that methods and
properties are becoming declared as private means that the framework is in
the stage of its maturity, where we think of opening legit ways for its
extension, while eliminating possibility of hacks.

Best,

--
*Bulat Shakirzyanov* | Software Alchemist

*a: *about.me/avalanche123
*e:* mallluh...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin Eberlei  
View profile  
 More options Mar 10 2011, 3:21 am
From: Benjamin Eberlei <kont...@beberlei.de>
Date: Thu, 10 Mar 2011 09:21:08 +0100
Local: Thurs, Mar 10 2011 3:21 am
Subject: Re: [symfony-devs] Re: Private methods and properties?
Just to give an example, Doctrine 2 has almost no protected only private
variables and strictly prevents inheritance in many cases:

What this enabled us to do in our development of 2.1 is to refactor the
internals of many of our central classes to allow for much better
performance and tons of new features that needed adjusting central parts of
the Doctrine classes.

With protected variables all this would not be possible, because we would
have to break BC.

There are very real benefits of the closed principle even for frameworks
and if they are maintained very well and bugs get fixed fast then there is
no problem. Frameworks like ZF need protected stuff because frankly most of
ZF components go into production releases where an "alpha" tag would be
useful. However the level of detail that went into the Symfony API and also
compared to other frameworks the "few tasks" it tries to solve (focus on
the relevant!) using private properties is actually a positive step towards
future enhancements of the framework.

One HUGE benefit here is the DI Container, almost everything in Symfony
has an interface. Just exchange the whole implementation! Yes you need to
copy the code, yes its more ocmplex to maintain FOR YOU. but in contrast,
the framework is much easier to maintain for us core developers and this
will benefit EVERYONE in the long run.

greetings,
Benjamin

On Wed, 9 Mar 2011 17:19:55 -0500, Bulat Shakirzyanov


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Hasoň  
View profile  
 More options Mar 10 2011, 6:08 am
From: Martin Hasoň <martin.ha...@gmail.com>
Date: Thu, 10 Mar 2011 03:08:47 -0800 (PST)
Local: Thurs, Mar 10 2011 6:08 am
Subject: Re: [symfony-devs] Re: Private methods and properties?

OK. But I don't understand one thing. The API (Symfony2 or Doctrine2)
consists only of public methods. Where is the break BC if I change the
protected method?

Yes the DI Container is huge benefit, but I don't want copy the code (copy
and paste programming is antipattern).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christophe COEVOET  
View profile  
 More options Mar 10 2011, 6:15 am
From: Christophe COEVOET <s...@notk.org>
Date: Thu, 10 Mar 2011 12:15:36 +0100
Local: Thurs, Mar 10 2011 6:15 am
Subject: Re: [symfony-devs] Re: Private methods and properties?
Le 10/03/2011 12:08, Martin Hasoň a écrit :
> OK. But I don't understand one thing. The API (Symfony2 or Doctrine2)
> consists only of public methods. Where is the break BC if I change the
> protected method?

> Yes the DI Container is huge benefit, but I don't want copy the code
> (copy and paste programming is antipattern).

Providing protected methods means the class is intended to be
inheritable (this is what protected is for). So using protected
everywhere means you allow the user to extend the core classes and
changing the protected methods would break the child classes. The only
real internal implementation is a private implementation.

--
Christophe | Stof


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ericclemmons  
View profile   Translate to Translated (View Original)
 More options Mar 9 2011, 8:23 pm
From: ericclemmons <e...@smarterspam.com>
Date: Wed, 9 Mar 2011 17:23:18 -0800 (PST)
Local: Wed, Mar 9 2011 8:23 pm
Subject: Re: Private methods and properties?
If you can extend the class, then you should be using `protected`.
Private, IMO, isn't entirely necessary and is only being used to try
and stop bad practices of those utilizing an open-source product.

Symfony is well designed, but there's no need to bind the hands of
whoever chooses to extend code for their own purposes.

I understand both sides to this debate.  In the same way that we use
getters/setters to avoid direct access to internals of a class via
public properties, we're now inheriting classes to go the same route
when they should share ownership.

To me, changing "protected" to "private" is spending cycles solving a
problem that either doesn't really exist, or isn't the framework's
problem to solve.

My $0.02 & change :)
--
Eric Clemmons

On Mar 9, 4:19 pm, Bulat Shakirzyanov <mallluh...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonathan Wage  
View profile  
 More options Mar 10 2011, 12:05 pm
From: Jonathan Wage <jonw...@gmail.com>
Date: Thu, 10 Mar 2011 11:05:43 -0600
Local: Thurs, Mar 10 2011 12:05 pm
Subject: Re: [symfony-devs] Re: Private methods and properties?

You have to also consider what this change forces us to do. Instead of just
solving the inheritance and extension problem by whoring out our API and
opening everything up we will have to specifically design for inheritance
and extension points. This will result in a much better experience for
everyone .You will have clear ways to extend and inherit things that are
designed for it, and we will have a much easier time maintaining and
evolving the internals of the code because we won't be breaking BC every
move we make. It may be hard to see now but fruits from this change
will definitely be apparent later in the life of Symfony2.

- Jon

--
Connect with me on *http://twitter.com/jwage* <http://twitter.com/jwage>
 and http://about.me/jwage to keep in touch.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukas Kahwe Smith  
View profile  
 More options Mar 10 2011, 12:10 pm
From: Lukas Kahwe Smith <m...@pooteeweet.org>
Date: Thu, 10 Mar 2011 18:10:30 +0100
Local: Thurs, Mar 10 2011 12:10 pm
Subject: Re: [symfony-devs] Re: Private methods and properties?

On 10.03.2011, at 18:05, Jonathan Wage wrote:

> You have to also consider what this change forces us to do. Instead of just solving the inheritance and extension problem by whoring out our API and opening everything up we will have to specifically design for inheritance and extension points. This will result in a much better experience for everyone .You will have clear ways to extend and inherit things that are designed for it, and we will have a much easier time maintaining and evolving the internals of the code because we won't be breaking BC every move we make. It may be hard to see now but fruits from this change will definitely be apparent later in the life of Symfony2.

exactly ... this change doesnt mean "no inheritance" .. it means carefully guided and designed inheritance extension points. less guessing about which of the 3-5 different possible ways to do something to choose. more consistency across Bundles follows naturally.

as a result of stopping this gigantic kitten slaughter we might end up with a kitten plague ;)

regards,
Lukas Kahwe Smith
m...@pooteeweet.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ericclemmons  
View profile  
 More options Mar 10 2011, 12:29 pm
From: ericclemmons <e...@smarterspam.com>
Date: Thu, 10 Mar 2011 09:29:01 -0800 (PST)
Local: Thurs, Mar 10 2011 12:29 pm
Subject: Re: Private methods and properties?
+1 Lukas + Jonathan's comments, specifically in regards to reducing BC
breaks and reducing extension points to a manageable number.

So, the code in the future will have a lot less of manipulation of
"$this->fooObject", but rather manipulating "$this->getFooObject()"
because of the constrained API?

You're right.  Down the line, forcing a gateway to object properties
will prove beneficial, especially if the getter does something more
than simply returning the property value, such as lazy-loading an
object or dispatching an event.

Thanks for the clarification, fellows!

On Mar 10, 11:10 am, Lukas Kahwe Smith <m...@pooteeweet.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Richtermeister  
View profile  
 More options Mar 10 2011, 1:52 pm
From: Richtermeister <nex...@gmail.com>
Date: Thu, 10 Mar 2011 10:52:00 -0800 (PST)
Subject: Re: Private methods and properties?
Hi all,

interesting read. An example that comes to mind are bind() vs.
doBind(), and save() vs. doSave() in the object form classes, where
only the do* methods are supposed to be overriden, yet that nugget of
wisdom is only in the phpdoc comment and is easily overlooked, so lots
of code I see has the bind() & save() methods overridden directly.

+1 for private.

Daniel

On Mar 10, 9:29 am, ericclemmons <e...@smarterspam.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Georg  
View profile  
 More options Mar 10 2011, 2:26 pm
From: Georg <geor...@have2.com>
Date: Thu, 10 Mar 2011 20:26:27 +0100
Local: Thurs, Mar 10 2011 2:26 pm
Subject: Re: [symfony-devs] Re: Private methods and properties?
Yes, interesting discussion.
What I understood is that symfony2 is such a sophisticated framework
that every possible use case is already taken care of, and because of
that everything should be private/final. If you are sure that's the case...
In my opinion having to copy the code of a class to add a small feature
is very bad for maintainability (yes, the framework user's, not the
framwork developer's). In case of a security problem, this leads to
sites patched late or not at all.
Why not just put a sentence in the documentation: "protected
properties/methos are not part of the API and can be changed any time"?

Am 10.03.2011 19:52, schrieb Richtermeister:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lukas Kahwe Smith  
View profile  
 More options Mar 10 2011, 2:34 pm
From: Lukas Kahwe Smith <m...@pooteeweet.org>
Date: Thu, 10 Mar 2011 20:34:08 +0100
Local: Thurs, Mar 10 2011 2:34 pm
Subject: Re: [symfony-devs] Re: Private methods and properties?

On 10.03.2011, at 20:26, Georg wrote:

> Yes, interesting discussion.
> What I understood is that symfony2 is such a sophisticated framework
> that every possible use case is already taken care of, and because of
> that everything should be private/final. If you are sure that's the case...

no we are not sure that this is the case. so we will review requests to open the API on a case by case basis. we are just reversing from defaulting to protected to defaulting to private.

> Why not just put a sentence in the documentation: "protected
> properties/methos are not part of the API and can be changed any time"?

because that would also not be correct, since we do have places where we invite users to inherit and reuse methods.

regards,
Lukas Kahwe Smith
m...@pooteeweet.org


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dbenjamin  
View profile  
 More options Mar 11 2011, 3:56 am
From: dbenjamin <bd.web...@gmail.com>
Date: Fri, 11 Mar 2011 00:56:22 -0800 (PST)
Local: Fri, Mar 11 2011 3:56 am
Subject: Re: [symfony-devs] Re: Private methods and properties?

+1 for privates.
+1 for good usage of the final keyword as it can be a great tool to preserve
code consistency and to control "what" the developer can override.
A great example is for final constructors which call explicitly a
initialize() method to allow developer to do "extra" stuff.

+1 because it's a pain in the ass when you start a huge project with a
version of a framework and when at some point you want to update your
vendors with the last releases to benefit of all the new stuff and bugfix
and improvements and all. How many of us just said one day : "Hum it's
working well as it is, why touching anything ? Just let it on this 2 years
ago release, as long as it works :)"

"Design by contract" ! That's the Symfony 2 approach here, and that's what
the end-user should do ! The DIC is a great tool. That's the best approach
for the developer on so many points and particulary to have total control of
its code, instead of overriding all he sees. (Take Magento for instance,
it's a nightmare).

I just want to be able to update my vendors at any time, and don't want to
be stressed about it. I just want to read the change log and say "Yeah cool
stuff. Hum, nice the bug is finally fixed !", and then play around with
my Care Bears friends :-)

Cya

--
Benjamin Dulau - anonymation CEO
anonymation.com | code.anonymation.com
ben...@anonymation.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johannes  
View profile  
 More options Mar 11 2011, 7:05 am
From: Johannes <johannes.schmitt...@googlemail.com>
Date: Fri, 11 Mar 2011 04:05:03 -0800 (PST)
Local: Fri, Mar 11 2011 7:05 am
Subject: Re: Private methods and properties?
Another question which we haven't really talked about when do we use a
protected property, and when do we use a private property but add
getters? In PHP, the latter is generally slower than allowing direct
access to the property, but giving direct access to the property will
effectively make the property mutable as we have no way to declare it
final or otherwise immutable.

How should we handle these cases? Generally, add setters/getters and
if performance is impacted make the property protected but clearly say
that we do not guarantee BC for the property, but that users should
use the setters/getters instead?

Kind regards,
Johannes

On 11 Mrz., 09:56, dbenjamin <bd.web...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ericclemmons  
View profile  
 More options Mar 11 2011, 1:50 am
From: ericclemmons <e...@smarterspam.com>
Date: Thu, 10 Mar 2011 22:50:51 -0800 (PST)
Local: Fri, Mar 11 2011 1:50 am
Subject: Re: Private methods and properties?
For the most part, isn't it safe to assume that for each property,
there will likely be an appropriate getter/setter?

Classes where properties are internally tracking state, caches, etc.,
may not have a public accessor method for such granular, internal
data, but that would be one of those situations where opening up the
API for extension purposes may make sense.

Great discussion, btw.

On Mar 10, 1:34 pm, Lukas Kahwe Smith <m...@pooteeweet.org> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Lemke  
View profile   Translate to Translated (View Original)
 More options Mar 11 2011, 3:21 am
From: Robert Lemke <rob...@typo3.org>
Date: Fri, 11 Mar 2011 00:21:18 -0800 (PST)
Local: Fri, Mar 11 2011 3:21 am
Subject: Re: Private methods and properties?
Hi Lukas,

On 10 Mrz., 20:34, Lukas Kahwe Smith <m...@pooteeweet.org> wrote:

> > Why not just put a sentence in the documentation: "protected
> > properties/methos are not part of the API and can be changed any time"?

> because that would also not be correct, since we do have places where we invite users to inherit and reuse methods.

that's right. What about public methods which are not really meant to
be part of the public API (but need to be public for internal
framework use) – do you have a specific way to warn developers that
they shouldn't use them?

(see http://robertlemke.de/blog/posts/2011/03/11/protected-vs-private
for our current approach in FLOW3)

Would be perfect to have a common concept / convention for the bigger
PHP projects and if we find one, we'd gladly refactor our code to meet
it.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bulat Shakirzyanov  
View profile  
 More options Mar 11 2011, 5:00 pm
From: Bulat Shakirzyanov <mallluh...@gmail.com>
Date: Fri, 11 Mar 2011 17:00:52 -0500
Local: Fri, Mar 11 2011 5:00 pm
Subject: Re: [symfony-devs] Re: Private methods and properties?

If a method is public, it can be used from outside, not matter how internal
the class is.
If its an internal class, and its critical an you don't want users to abuse
that method, declare it final.
The change is not about preventing developers from using some methods, go
for it, you can use any
public method. It is about closing points of unexpected inheritance, and
leaving places for developers
to extend the framework by providing alternative implementations.

As I replied to someone on twitter its best to refactor code to inheritance
instead of designing for it.
In that sense Symfony2 is the only framework, where Controllers and Models
and Views don't require
any base class. This way we don't force any developer into our own
inheritance trees, leaving most
of their code re-usable and framework agnostic.

Everzet also posted a fine comparison on twitter:

http://twitter.com/everzet/status/45632267107835904
http://twitter.com/everzet/status/45630401347207168

If you spot a case where you want to get ahold of a private property/method,
please make your case
and we will either tell you how to do it best using existing means, or open
up the above-mentioned
member to inheritance.

When framework developers only use protected methods and don't close classes
for inheritance, it
is not because they want the framework to be extensible to the very core.
For the most part, it is
because they are simply lazy to craft proper extension paths.

Best,

--
*Bulat Shakirzyanov* | Software Alchemist

*a: *about.me/avalanche123
*e:* mallluh...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Johannes Schmitt  
View profile  
 More options Mar 11 2011, 8:05 pm
From: Johannes Schmitt <schmitt...@gmail.com>
Date: Sat, 12 Mar 2011 02:05:00 +0100
Subject: Re: [symfony-devs] Re: Private methods and properties?

I think the question is not so much "if" but more how we do it. Right now, I
have changed most visibility from protected to private for the Security
component. However, there are some cases where I'd like to keep protected
properties for performance reasons instead of declaring something as private
plus adding a getter. However, that weakens the contract as all properties
in PHP are mutable.

Also, you cannot generally say that all public methods are equal. In Java
for example, constructs like this are possible:

class Foo {
   private class Bar {
      private $property;

      public getProperty()
      {
        return $this->property;
      }
   }

}

We cannot enforce this in PHP via code, but we could add annotations like
Robert suggests. The question is how far do we want to go, and do we want to
have general guidelines when to use which strategy.

Kind regards,
Johannes

On Fri, Mar 11, 2011 at 11:00 PM, Bulat Shakirzyanov
<mallluh...@gmail.com>wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Georg  
View profile  
 More options Mar 12 2011, 12:18 pm
From: Georg <geor...@have2.com>
Date: Sat, 12 Mar 2011 18:18:44 +0100
Local: Sat, Mar 12 2011 12:18 pm
Subject: Re: [symfony-devs] Re: Private methods and properties?

Am 11.03.2011 23:00, schrieb Bulat Shakirzyanov:

> If you spot a case where you want to get ahold of a private
> property/method, please make your case
> and we will either tell you how to do it best using existing means, or
> open up the above-mentioned
> member to inheritance.

I have seen this argument a lot. Have you checked lately how many issues
on the tracker of doctrine 1.2 for example have not even been
read/commented by a developer in the last half year because all efforts
go to doctrine 2.0?
Today when everything is new, those changes will be done quickly. But
later? And I do not expect a developer searching for a solution will
want to wait for some months for a change, and be dependent on the good
will of a developer. So this probably means that you have to use your
own git clone then. And I am not sure how easy this is if you are using
another SCS for your own projects. Generally I feel that a developer
should be able to use the whole framework as he/she sees fit, and not
like the framework developers expect it's best for him/her (which it
certainly is in most cases, but not in all).

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Messages 1 - 25 of 27   Newer >
« Back to Discussions « Newer topic     Older topic »