On Sun, Apr 6, 2008 at 6:18 AM, tstarling@svn.wikimedia.org wrote:
- Use protected instead of private. Private should not be used ever.
That's a pretty strong statement. If you use protected, you can't freely change around the methods unless you're sure nobody's actually extended the class (in which case, what harm would there have been in using private to start with?). If you use private, you can always change it to protected later if it's useful, but not vice versa.
Yeah, I'd have to agree with that. There are some things that extending and fiddle around with should be discouraged.
Simetrical-3 wrote:
On Sun, Apr 6, 2008 at 6:18 AM, tstarling@svn.wikimedia.org wrote:
- Use protected instead of private. Private should not be used ever.
That's a pretty strong statement. If you use protected, you can't freely change around the methods unless you're sure nobody's actually extended the class (in which case, what harm would there have been in using private to start with?). If you use private, you can always change it to protected later if it's useful, but not vice versa.
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Simetrical wrote:
On Sun, Apr 6, 2008 at 6:18 AM, tstarling@svn.wikimedia.org wrote:
- Use protected instead of private. Private should not be used ever.
That's a pretty strong statement. If you use protected, you can't freely change around the methods unless you're sure nobody's actually extended the class (in which case, what harm would there have been in using private to start with?). If you use private, you can always change it to protected later if it's useful, but not vice versa.
That's what grep is for.
I'm generally against visibility/access control in object oriented programming. Protected is a compromise.
-- Tim Starling
On Mon, Apr 7, 2008 at 2:47 AM, Tim Starling tstarling@wikimedia.org wrote:
That's what grep is for.
And that works how, for third-party extensions? Just let them break unless they're checked into our repo?
I'm generally against visibility/access control in object oriented programming.
I've noticed . . .
Simetrical wrote:
On Mon, Apr 7, 2008 at 2:47 AM, Tim Starling tstarling@wikimedia.org wrote:
That's what grep is for.
And that works how, for third-party extensions? Just let them break unless they're checked into our repo?
I'm generally against visibility/access control in object oriented programming.
I've noticed . . .
Extensions can just as easily be broken by excessive access control. Excessive access control leads to code duplication, when the functionality in private methods is duplicated in the external project by copying and pasting. Such duplication may lead to breakage when the original method is updated, and it turns review into a game of "spot the difference".
Sometimes access control will simply kill a project dead, with no progress being possible except via a core patch.
So I find it hard to believe that access control is for the benefit of the extensions. Rather, I think it's because the people who develop the core code fail to recognise the general applicability of what they write, and so, following the coding convention from other projects, apply private access control by default.
If you want to document the expected stability of an interface, you can do it with a comment. Let the extension developer decide whether it is worthwhile to them to use an unstable interface.
-- Tim Starling
On Mon, Apr 7, 2008 at 10:16 AM, Tim Starling tstarling@wikimedia.org wrote:
Extensions can just as easily be broken by excessive access control. Excessive access control leads to code duplication, when the functionality in private methods is duplicated in the external project by copying and pasting. Such duplication may lead to breakage when the original method is updated, and it turns review into a game of "spot the difference".
Sometimes access control will simply kill a project dead, with no progress being possible except via a core patch.
In principle, that depends on how thoughtful you are in what methods you make public, but in practice I guess you're right, yes.
So I find it hard to believe that access control is for the benefit of the extensions. Rather, I think it's because the people who develop the core code fail to recognise the general applicability of what they write, and so, following the coding convention from other projects, apply private access control by default.
If you want to document the expected stability of an interface, you can do it with a comment. Let the extension developer decide whether it is worthwhile to them to use an unstable interface.
Maybe so.
wikitech-l@lists.wikimedia.org