Is this Factory Method creation pattern?

前端 未结 20 832
再見小時候
再見小時候 2020-12-12 17:12

I have been using factory method creation pattern for awhile now. I was just recently told that this:

public static class ScheduleTypeFactory
{
    public st         


        
20条回答
  •  既然无缘
    2020-12-12 17:50

    Yes this is a factory pattern. My only comment would be that you fail silently for enum values that you don't specifically handle. That may be expected but I like to add the following to the end of statements like that

    default:
      throw new InvalidOperationException("Invalid Enum Value");
    

提交回复
热议问题