Re:Software Design Patterns Are Not Goals, They Are Tools
by awinter-py on Thursday May 19, 2016 @12:20PM
(#11731327)
Yes, I meant 'callback' is a better title than 'visitor pattern', not that callbacks are obvious without explanation.
Re:Software Design Patterns Are Not Goals, They Are Tools
by jrochkind1 on Thursday May 19, 2016 @04:10PM
(#11733376)
A difference of opinion about what a pattern should be called is not an argument against the utility of the concept of design patterns.
It's definitely called 'callback' in Javascript, I don't know if that name would be as obvious or useful in other environments.
To a new programmer, say in javascript, who has never seen them before, they aren't at all self-descriptive or obvious. It is super helpful to have the term 'callback' to talk about them, and to understand what they are -- say, just a function you pass in that's then called back or whatever.
Then you'll be able to recognize what it is when you see it in existing code/api, and how to use it, as well as when to use it when writing your own code/api. If you really just tossed someone at Javascript and they were a new programmer and had no idea what a 'callback' was, most people would have a lot more trouble figuring it out from themselves only from code examples, or would never think of using it themselves when writing code/api never having seen it before.
That's all a "design pattern" is. "Callback function" is a common and successful design pattern in Javascript. (Less common or useful in some other languages, depending on the affordances of the platform). That's it.
Yes, focusing on "what's being used" instead of "what's happening" is a problem, yes, thinking you can construct software just by robotically putting together "design patterns" is a problem.
Design patterns are still a useful and inevitable part of software development, and recognizing that can make you much more efficient at learning how to write software, at designing comprehensible and maintainable software, and at reading other people's software.