Re: Java Question

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Java Question

ThSITC
Thank you so much, my Java teacher!
Thomas.

PS: I forward this again to ibm-netrexx, as this explanation might serve to be cited in the
upcoming NetRexx Users guide ;-)

Thomas Schneider.
====================================================================================
Am 22.06.2012 06:59, schrieb Alan Sampson:
Thomas,

Data-hiding and polymorphism are cornerstones of the object-oriented methodology.  In OO programming an important consideration what should be part of the public interface and what should be hidden.  In general a design should only expose as little as possible to the public interface as this becomes the contract between the interface designer and his users.  All other implementation details should be kept private to reduce the impact of any underlying changes to the customer base.

In the example under discussion the method is defined in the parent class as protected which means it isn't part of the public interface but can be overloaded by subclasses (children) when they need to modify its behaviour.  That's what's happening here, the subclass creates a method which can only be called by other objects of the same type and this is exactly what the designers intended.  Now when the system registers the object in the example it doesn't care that it's a subclass of the object it expects, it's only aware that it has an object of the expected type so when it drives the method it's the one from the subclass that is invoked (polymorphically), not the default method from the parent.

Alan.

On Thursday, 21 June 2012, Thomas Schneider wrote:
Hi Alan,
 1.) Sorry that Idid forward ur private Conversation to ibm-netrexx without asking you!
Didn't actually know that this breaks some rules ... :-(
 2.) In you recent mail to ibm-netrexx you wrote:

Note too that getPasswordAuthentication() is a protected method so it can only be called polymorhically or from instances of the inner class and/or it's children.

 Could you explain this to me a bit, please! My oo and Java knowlede has to be improved (I do nt understand what this means :-)

 Thanks in advance, Thomas.

PS: When you feel hat this might interest others on ibm-netrexx, feel free to copy reply to ibm-netrexx!

--
Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org)


--
Can't tweet, won't tweet!


--
Thomas Schneider (Founder of www.thsitc.com) Member of the Rexx Languge Asscociation (www.rexxla.org) Member of the NetRexx Developer's Team (www.netrexx.org)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com