| 
	
 | 
 Posted by Henk Verhoeven on 06/26/06 16:32 
Jerry Stuckle wrote: 
  > Actually, things like private declarations are very important. 
 
IMHO private declarations are too rigid and therfore decrease  
reusability. I agree that it can be very usefull to know the intentions  
of the developer of some code one is  evaluating to call or some member  
variable one is avaluating to access. But every now and then there are  
good reasons to do it anyway, even if it was intended to be private. For  
example lazy initialization and default reasoning both are often  
implemented using direct access to member variables. Another example is  
using a visitor to implement persistency. 
 
Now maybe you would say that i should change these member variables to  
protected or public. There are two problems with this: 
1. It may not be my own code. Then if i get an upgrade of this code,  
these member variables will once again be private, unless i re-apply my  
changes. This is uneccessary overhead. 
2. By changing the private declaration the intension of the other  
developer gets lost. Now i could put a comment in that it was intended  
to be private, but in that case: why not put the @private marker in the  
comment in the first place? 
 
The fundamental point is: With these private and protected declarations  
you get stuck with the uneccessarily limitations introduced by the  
author. Object-orientation can lead to more reusability then  
conventional parameterized code exactly because the code can be  
overridden and extended in ways the original author did not provide for.  
private and protected declarations are a step backwards that is only  
reasonable if you assume that future developers that will maintain or  
reuse your code will ignore your intentions becuase they are fools. If  
this is the case, i think you should tell your boss that you are  
limiting the reusability of your code because you are aniticipating him  
to hire fools and let them work on/with your code ;-) 
 
Greetings, 
 
Henk Verhoeven, 
www.phpPeanuts.org.
 
  
Navigation:
[Reply to this message] 
 |