Add sample for factory pattern