vendredi 14 février 2020

Is Extending Class Queue into Class Stack Break Liskov Principle?

if I have Class Queue

class Queue {
  pop () {
   return 'Last value of Array'
  }
}

and Class Stack

class Stack extends Queue {
  @Override
  pop () {
   return 'First value of Array'
  }
}

Is it breaking Liskov Substitution Principle? and why?

Aucun commentaire:

Enregistrer un commentaire