lundi 14 mars 2016

Strategy Pattern - "No Action" behavior

When we are using the strategy pattern, is a bad idea to implement an "No Action" interface?

Example:

interface IFlyBehavior
{
    void Fly();
}

class UpperFlyBehavior : IFlyBehavior
class UglyFlyBehavior : IFlyBehavior

class NoFlyBehavior : IFlyBehavior

The NoFlyBehavior has an emtpy implementation of the Fly() method.

It seems a little strange to have an implementation of a method that does nothing.

Aucun commentaire:

Enregistrer un commentaire