Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods vs function #4

Open
lgatto opened this issue Apr 6, 2015 · 1 comment
Open

Methods vs function #4

lgatto opened this issue Apr 6, 2015 · 1 comment

Comments

@lgatto
Copy link
Member

lgatto commented Apr 6, 2015

@sgibb commented

I have seen that you change some methods to functions in some of your packages. What is the reason for that? Is there any drawback of S4 methods (except that dispatching needs some time and debugging is sometimes harder)?

@lgatto
Copy link
Member Author

lgatto commented Apr 6, 2015

That's it:

except that dispatching needs some time and debugging is sometimes harder

The time involved for dispatching is generally negligible. Debugging is however always (at least a bit) harder. One can make the method call an internal function to facilitate debugging, but that makes the general structure of the software harder to grasp.

But I think you've got the wrong end of the stick. The question is not 'why not use S4 methods' but 'why use S4 methods'. And, IMHO, the answer to that is because the functionality is used in many different places. This happens because the name is very generic (normalize, smooth, ...) and/or used in many different context (plot, ...). When none of these apply, I am questioning the need for a generic/method. This is also valid for most of the accessors and replacement functions, which can be implemented as functions, and I don't see why generics/methods are more appropriate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant