jeudi 23 avril 2020

What should I name the class that represents a state machine?

I am working on a OO code base, C# but that is irrelevant, and I am questioning the name of the class and not sure what is the "correct and descriptive" to use.

The code is taking an input and it goes through a series of validations (state machine like) and at the end performs a task.

Current code:

public static class ProcessingFactory
{
    public static IProcessor GetNextProcessor(IProcessor processor = null)
    {
        if processor == null)
        {
            return new AProcessor();
        }

        if processor is AProcessor)
        {
            return new BDeviceProcessor();
        }

        if (processor is BProcessor)
        {
            return new CProcessor();
        }

        return null;
    }
}

I believe the class name is misleading as I don't think of it as a factory.

If you agree, what is a more appropriate name?

If you don't, why do you think this is a classic factory pattern?

Aucun commentaire:

Enregistrer un commentaire