A facade pattern implements light-weight methods on top of an underling work-horse function. Usually each method does some preliminary processing before invoking the work-horse function. In the simple case where there is no preliminary processing and you have no interest in the return value of setClass, it makes sense to use a for loop rather than lapply. So
.my_summary <- function(object, ...) {}
for (cl in all_classes())
setMethod(summary, cl, .my_summary)
Also, that .my_summary
works on several classes implies that the classes share common structure, hence might be arranged into a class hierarchy and a method defined on the base class.
setClass("A", representation(x="numeric"))
setClass("A1", contains="A")
setClass("A2", contains="A")
setMethod(summary, "A", function(object, ...) {})
In S4 one can use multiple inheritance to provide a kind of aspect-oriented programming
setClass("Summary")
setMethod(summary, "Summary", function(object, ...) {})
setClass("B1", contains=c("A", "Summary"))
B1 then inherits data (slot x) from A, and behavior from Summary. Method dispatch in this case can get confusing (which method is selected if both A and Summary have a summary method?).