Created
June 8, 2012 15:15
-
-
Save JuanjoFuchs/2896112 to your computer and use it in GitHub Desktop.
Ejemplo del principio de sustitución de Liskov (LSP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace LSP_Animal.Refactorizado | |
{ | |
public abstract class Animal | |
{ | |
public abstract void Alimentar(); | |
} | |
public interface IMascota | |
{ | |
void Acariciar(); | |
} | |
public class Perro : Animal, IMascota | |
{ | |
public override void Alimentar() | |
{ | |
// Alimentar al perro | |
} | |
public void Acariciar() | |
{ | |
// Acariciar al perro | |
} | |
} | |
public class Escorpion : Animal | |
{ | |
public override void Alimentar() | |
{ | |
// Alimentar al escorpion | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace LSP_Animal.SinRefactorizar | |
{ | |
public abstract class Animal | |
{ | |
public abstract void Alimentar(); | |
public abstract void Acariciar(); | |
} | |
public class Perro : Animal | |
{ | |
public override void Alimentar() | |
{ | |
// Alimentar al perro | |
} | |
public override void Acariciar() | |
{ | |
// Acariciar al perro | |
} | |
} | |
public class Escorpion : Animal | |
{ | |
public override void Alimentar() | |
{ | |
// Alimentar al escorpion | |
} | |
public override void Acariciar() | |
{ | |
// Estas loco ????! | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment