commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derek-Ashmore <>
Subject [GitHub] commons-lang pull request: Lang 1195: Enhance MethodUtils to allow...
Date Fri, 13 May 2016 11:17:41 GMT
Github user Derek-Ashmore commented on the pull request:
    Thanks for taking time to respond.  I should be challenged on the need 
    for this.  I grant your point-- over-exposing methods is technically 
    possible.  I've issues with that, however.
     From an design perspective, you should only expose fields (through 
    accessors/mutators) and methods you intend to expose.  That is, that are 
    being made available for use by other classes or by inheritance. 
    Over-exposing methods and fields in the way you describe violates OO 
    design principles.  Creating an easy way for test code to access 
    privates is less of a principle breach; test classes presumably know 
    exactly how a class is supposed to operate and are tightly coupled to 
    that class anyway.
    Why create FieldUtils?  That logic should also have been used to not 
    implement the methods on FieldUtils that allow you to manipulate private 
    fields. Doesn't that run into the same issue?
    I don't like over-exposing fields and methods just to be able to cover 
    them in testing.  I'm not alone.
    Thanks for taking a look at this request and taking time to comment.  
    Thanks, also, for the most interesting discussion.
    Derek <> 
    <> <>
    Please note that my email address has changed to
    On 5/13/2016 5:23 AM, sebbASF wrote:
    > Note that an alternative solution for testing private methods is to 
    > make them package-protected.
    > (and document why they are not private!)
    > The test code needs to access it from the same package, but that is 
    > not usually a problem.
    > If necessary create a public method in the same package which can be 
    > used by all the test code.
    > A similar approach can be used for private fields; create a 
    > package-protected getter.
    > —
    > You are receiving this because you authored the thread.
    > Reply to this email directly or view it on GitHub 
    > <>

If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message