3 ms·
Honest question: I hear these terms used quite a bit. What qualifies as patterns/anti-patterns? (From my naive understanding, patterns are some language featur
by srvmshr 5y ago
Honest question: I hear these terms used quite a bit. What qualifies as patterns/anti-patterns?
(From my naive understanding, patterns are some language features which should be used over conventionally accepted ways. Please correct if wrong)
- lmm 5y agoPatterns are not really language features so much as the lack of them - they're "standardised" ways of solving a problem that the language doesn't have a feature for, so that at least everyone is writing the same thing and a reader might be able to understand the code at a glance. Anti-patterns are pretty much the same thing, just where there is some problem with the common solution that everyone is using - perhaps there actually is a language feature that addresses this use case after all, for example.
- srvmshr 5y agoSo if I write a recursive function to calculate factorial of a number (or some permutation calculator), will that be considered a pattern? Because Python3 wouldn't have the factorial built-in. Thank you for the explanation above.
- lmm 5y agoOnce isn't a pattern, factorial isn't normally seen as a language feature. Implementing recursion via the Y combinator is a pattern (for languages that don't have built-in recursion) because you do it again and again for many different functions.