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).
82 people like thisPosted: 13 years ago by Tao Liu
Observer pattern in F#
34 people like thisPosted: 13 years ago by Tao Liu
the interest rate is decided by the internal state: account balance
34 people like thisPosted: 13 years ago by Tao Liu
Command pattern for redo-undo scenario.
47 people like thisPosted: 13 years ago by Tao Liu
singleton pattern in F#
39 people like thisPosted: 13 years ago by Tao Liu
Proxy pattern is a class functioning as an interface to something else.
37 people like thisPosted: 13 years ago by Tao Liu
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.
90 people like thisPosted: 13 years ago by Tao Liu
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.
38 people like thisPosted: 13 years ago by Tao Liu
demonstrate how to use object expression to create a WPF/Silverlight command.
22 people like thisPosted: 12 years ago by Tao Liu
implement the decorate pattern in F#. The decorate pattern is to add new featuures to an object at runtime.
36 people like thisPosted: 13 years ago by Tao Liu
Strategy pattern in F#
83 people like thisPosted: 13 years ago by Tao Liu
Invoke the methods from incompatible types
110 people like thisPosted: 13 years ago by Tao Liu
use composite pattern to construct a tree and visitor pattern to bring back the traverse result.
34 people like thisPosted: 13 years ago by Tao Liu
Factory pattern in F#
81 people like thisPosted: 13 years ago by Tao Liu
Unlike the previous chain of responsibility, this version use the pipeline to chain responsibilities.
104 people like thisPosted: 13 years ago by Tao Liu
This command redo-undo implement group the command under Do/Undo category.
70 people like thisPosted: 13 years ago by Tao Liu
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.
27 people like thisPosted: 13 years ago by Tao Liu