Timeline for Can other behavioral OOP design patterns be expressed in terms of Strategy and Template Method Patterns for behaviour parameterization?
Current License: CC BY-SA 4.0
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 4, 2020 at 17:14 | comment | added | Christophe | @TahaYavuzBodur I think morover that many of these patterns can be applied to dynamic languages. As soon as you have a mean to pass a function object or a function reference, you have the tools to build them. In pure functional many of those patterns make no sense (e.g. no state, no observer). But some still make sense: a strategy function can be passed as parameter to a function to influence the behavior. A higher order function could even be used to determine the right strategy of the context function. But that would lead to a very different (and long) discussion ;-) | |
| Jul 4, 2020 at 17:09 | comment | added | Christophe | @TahaYavuzBodur you are fully right to ask the question which is very interesting. And indeed, composition over inheritance is the common implementation pattern here. I wanted to highlight a mental trap: design patterns are for design problems. Otherwise, they would be called implementation patterns (or idioms) ;-). Also, they build on top of polymorphism. If you would have no polymorphism at all, these patterns would not help. You'd first need to implement some kind of dispatch (you can do this in non-OOP languages such as C with for example aggregates of function pointers). | |
| Jul 4, 2020 at 16:33 | comment | added | Taha Yavuz Bodur | And when you analyze structures you see some similarities which leads me to ask this question. While I agree intent perspective makes them universal and when you think in a solution its natural and helpful, it makes it hard to grasp the pattern in its own, since you work in the language environment so you are inclined to think in its techniques IMHO. Secondly, I agree in my reasoning it's hard to cover observer and visitor, but Chain of Responsibility and some others looked like possible to me. | |
| Jul 4, 2020 at 16:20 | comment | added | Taha Yavuz Bodur | Thank you for the nice response, but I want clarify two things that may contribute to this. I tried not to say behavioral patterns are for OOP polymorphism, but rather that mechanism makes it possible to implement them and try to state that other paradigms have other mechanisms for that. GoF patterns are especially for static-typed OOP languages, but as you mentioned I see that they tell from intent perspective to make them universal patterns. The point is when you work with e.g. Java, to really use that patterns you feel to understand the structure also. | |
| Jul 4, 2020 at 13:35 | history | edited | Christophe | CC BY-SA 4.0 | added 180 characters in body |
| Jul 4, 2020 at 13:25 | history | answered | Christophe | CC BY-SA 4.0 |