Is this a well known design pattern? What is its name?

前端 未结 8 1547
滥情空心
滥情空心 2020-12-06 04:54

I have seen this often in code, but when I speak of it I don\'t know the name for such \'pattern\'

I have a method with 2 arguments that calls an overloaded method t

相关标签:
8条回答
  • 2020-12-06 05:15

    I'd say this is pretty much a c# < 4 work around for lack of default arguments. if you prescribe to the 'patterns are missing language features' school of thought i guess you could say its a pattern, though not one that commonly gets named.

    edit: ok your update has really thrown me, i don't see what your are trying to do with a public method calling a private method. as far as the public api is concerned you could just move all the private methods code into the public method and have a local variable for the 'defaulted' value. or are both methods also called from other places in the class?

    0 讨论(0)
  • 2020-12-06 05:24

    It's an example of a helper method. Sheesh people, not being in the Gang of Four book doesn't stop it being a pattern. In the specific case where there helper is public and the helped method is private it's an example of encapsulation. Possibly a little too much encapsulation in this case.

    0 讨论(0)
提交回复
热议问题