Re: protected or private
- From: Bruno Desthuilliers <bdesth.quelquechose@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Feb 2006 01:16:42 +0100
Marcelo Pinto a écrit :
Bruno Desthuilliers escreveu:
Marcelo Pinto a écrit :
bruno at modulix wrote:
[snip]
Do so, and be sure a lot of programmers will hate you.
You should use 'private' *only* when you want to make sure a derived
class will not be able to access this given attribute.
I could not desagree more. Make everything private.
<troll>
Sir, Yes Sir !
And don't forget bondage, chains and the whip.
</troll>
Could you imagine a language with no access restrictors - only coding
conventions ?
You can think of access restrictors as code conventions reinforced by
the compiler.
No. I can think of access restrictors as an arbitrary and useless restriction enforced by the compiler/interpreter/whatever...
If you have a code convention that says that some members
of a class are not intended to be messed by anyone, then there is no
reason not to reinforce this restriction with some hard help.
Yes there is a reason: I do not pretend knowing in advance each and every possible use case for code I wrote, so I don't see any reason to make it harder than necessary for anyone to do whatever he wants to do with it.
.
- Follow-Ups:
- Re: protected or private
- From: Marcelo Pinto
- Re: protected or private
- References:
- protected or private
- From: tailorma_de
- Re: protected or private
- From: wayne
- Re: protected or private
- From: tailorma_de
- Re: protected or private
- From: bruno at modulix
- Re: protected or private
- From: Marcelo Pinto
- Re: protected or private
- From: Bruno Desthuilliers
- Re: protected or private
- From: Marcelo Pinto
- protected or private
- Prev by Date: Re: With Agile methods, we are measuring the right things
- Next by Date: Re: With Agile methods, we are measuring the right things
- Previous by thread: Re: protected or private
- Next by thread: Re: protected or private
- Index(es):
Relevant Pages
|