4 ms·
DoF design patterns is Java bollocks IMO. It's only Java developers and to a lesser extent C# developers that really go nuts for this stuff. Visitor is clearl
by jpz 8y ago
DoF design patterns is Java bollocks IMO.
It's only Java developers and to a lesser extent C# developers that really go nuts for this stuff. Visitor is clearly a framework for expressing multimethods - thus one can say Visitor is merely a workaround for the constriction of expressiveness of a given language - which is a claim made about many of the GoF patterns.
Singletons as a pattern? How is that different to global variables? It isn't.
- charlysl 8y agoDesign patterns are just a convention; I would be as uncomfortable overusing them as jumping on the current pattern bashing fad. The Interpreter pattern is just a technique for doing what amounts to pattern matching but in an OO language, the Visitor is its dual, and Composite is handy to represent arbitrary arity trees. They allow you to represent algebraic types in an OO language, and I guess that they are design patterns because they can be applied systematically in any domain without having to reinvent the wheel, given that designing with them is driven by the information's structure only, just like in regular FP languages. Abusing them is just as bad as abusing any other design technique, but when applied correctly they greatly improve program structure and maintainability. Visitors have nothing to do with multimethods. Their purpose, in this context, is to improve maintainability when in a given functional program written in an OO language you would be more likely to add new functions rather than data type variants; Interpreter would be preferable when the opposite is the case. Do you know of better ways of systematically doing FP design in C++? The article doesn't mention any.
- nurettin 8y agoThe article isn't about design patterns, it is about using the new functional programming primitives which C++ relatively recently acquired through the standardization process. Suggesting to use a syntax for lambda or currying or transferring closure parameters or making copies of data in order to avoid thread problems is not remotely within the same category as "visitor pattern".
- charlysl 8y ago> it is about using the new functional programming primitives which C++ relatively recently acquired through the standardization process. Sorry, I couldn't find any mention of such new primitives in the article. Which are they?
- LgWoodenBadger 8y agoA singleton guarantees that one-and-only-one instance of that type/thing is instantiated. One can create as many global variables of that type/thing as one wants. Whether one refers to the same, singular instance everywhere is not something a global variable guarantees. One may use a global variable to implement a singleton, but they aren't the same at all.