Snippets created by Tao Liu
Chain of responsibility
The following sample wants to make sure the person’s age is between 18 and 65, weight is no more than 200 and tall enough (>120).
64 people like this
Posted: 9 months ago by Tao LiuDecorate pattern
implement the decorate pattern in F#. The decorate pattern is to add new featuures to an object at runtime.
35 people like this
Posted: 9 months ago by Tao LiuObserver pattern
Observer pattern in F#
33 people like this
Posted: 9 months ago by Tao LiuStrategy pattern
Strategy pattern in F#
59 people like this
Posted: 9 months ago by Tao LiuState Pattern
the interest rate is decided by the internal state: account balance
30 people like this
Posted: 9 months ago by Tao LiuAdapter pattern
Invoke the methods from incompatible types
72 people like this
Posted: 9 months ago by Tao LiuCommand pattern for Redo-Undo
Command pattern for redo-undo scenario.
43 people like this
Posted: 9 months ago by Tao LiuComposite pattern and Visitor Pattern
use composite pattern to construct a tree and visitor pattern to bring back the traverse result.
31 people like this
Posted: 9 months ago by Tao LiuSingleton Pattern
singleton pattern in F#
34 people like this
Posted: 9 months ago by Tao Liu
Factory Pattern
Factory pattern in F#
57 people like this
Posted: 9 months ago by Tao LiuProxy Pattern
Proxy pattern is a class functioning as an interface to something else.
37 people like this
Posted: 9 months ago by Tao LiuChain of responsibility II
Unlike the previous chain of responsibility, this version use the pipeline to chain responsibilities.
79 people like this
Posted: 8 months ago by Tao LiuWPF / SilverLight Converter II
version 1 is http://fssnip.net/62. This new version support convert from any existing function to a converter function by using composition and pipeline. The convert function is to make the function signature agree to the IValueConverter interface. You can add new functions in the FunctionLibrary module and reuse the class definition to reduce the coding effort. The first sample is to show how to make the converter pipeline work, the second one is a debugger converter used to debug the data binding problem.
74 people like this
Posted: 8 months ago by Tao LiuCommand pattern for Redo-Undo II
This command redo-undo implement group the command under Do/Undo category.
58 people like this
Posted: 8 months ago by Tao LiuTemplate pattern
Template pattern is a behavior-based pattern. Realized the importance of high order function, this is a way to use high order function. Still keep the type structure to organize my code.
34 people like this
Posted: 6 months ago by Tao LiuMake a chain of functions
Function composition can be done by using >> operator. The snippet at http://fssnip.net/S is a wonderful sample. But that version generates a function which is not easy when you want to debug. This version is to use pipeline (|>) operator.
26 people like this
Posted: 5 months ago by Tao LiuWPF Command in F#
demonstrate how to use object expression to create a WPF/Silverlight command.
17 people like this
Posted: 2 months ago by Tao Liu