Factory pattern example