40
5
| |
add comment |
41
|
Depends on how picky you are about hiding state.
If a developer comes along and subclasses your class they may mess it up because they don't understand it fully. With private members, other than the public interface, they can't see the implementation specific details of how things are being done which gives you the flexibility of changing it later.
| ||||||||||||
|
19
|
The general feeling nowadays is that they cause undue coupling between derived classes and their bases.
They have no particular advantage over protected methods/properties (once upon a time they might have a slight performance advantage), and they were also used more in an era when very deep inheritance was in fashion, which it isn't at the moment.
| ||
add comment |
14
|
Generally, if something is not deliberately conceived as public, I make it private.
If a situation arises where I need access to that private variable or method from a derived class, I change it from private to protected.
This hardly ever happens - I'm really not a fan at all of inheritance, as it isn't a particularly good way to model most situations. At any rate, carry on, no worries.
I'd say this is fine (and probably the best way to go about it) for the majority of developers.
The simple fact of the matter is, if some other developer comes along a year later and decides they need access to your private member variable, they are simply going to edit the code, change it to protected, and carry on with their business.
The only real exceptions to this are if you're in the business of shipping binary dll's in black-box form to third parties. This consists basically of Microsoft, those 'Custom DataGrid Control' vendors, and maybe a few other large apps that ship with extensibility libraries. Unless you're in that category, it's not worth expending the time/effort to worry about this kind of thing.
| ||
add comment |
cheap air jordan
ReplyDeletemichael kors handbags
adidas stan smith
michael kors uk
adidas stan smith men
fitflops sale
cheap nfl jerseys
christian louboutin shoes
nike air huarache
discount oakley sunglasses
huarache shoes
cheap basketball shoes
nike zoom
oakley sunglasses
http://www.oakley-sunglass.in.net
tiffany online
jordan shoes on sale
adidas nmd for sale
nike air zoom structure 19
yeezy shoes
air jordans,cheap air jordans,air jordan shoes,air jordan 11,air jordan 13,air jordan 6,air jordan 4