add factory pattern sample.