ServiceNow interview question

what is factory pattern? stack implementation code