Factory method pattern example