Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can you elaborate more on some the challenges you have faced with private methods?


Honestly I've never used them of my own volition. So it's not so much that I've faced problems with them, it's just that I've never felt like they solved any problem I had.

I don't even really use "methods" strictly speaking, in general I'll use a dictionary of functions if I want to group functions together semantically, and I'll emit such a dictionary from a closure if for example I need to precompute a lookup table to be used for multiple related calls.

I've had more negative experiences with being denied the ability to do something by overwrought architecture than shooting myself with a footgun someone left in, but importantly I think my approach generally leads to more composability and agility.


> I'll emit such a dictionary from a closure if for example I need to precompute a lookup table to be used for multiple related calls

Isn't this analogous to using private methods, though? I.e. you have some logic to precompute the lookup table that isn't accessible to users of your dictionary of functions? Am I misunderstanding how this works? Or are there benefits of this approach vs. for example having a private method "precomputeLookupTable()" that gets called in a class constructor?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: