lundi 12 juillet 2021

Is it "Strategy" or "Template Method" pattern? [closed]

I started to learn patterns recently, and i saw a lot of realizations of Strategy pattern like this, but my seniour friend said, that this is realization of "Template Method" pattern. What do you think about it?


interface IAnimal
{
void MakeSound();
}

class Dog : IAnimal
{
void MakeSound()
{
Console.WriteLine("hoof");
}
}

class Cat : IAnimal
{
void MakeSound()
{
Console.WriteLine("meow");
}

class Cow : IAnimal{
void MakeSound()
{
Console.WriteLine("moo");
}
}

Aucun commentaire:

Enregistrer un commentaire