2-PL-Design-Style Slide 29

Moderatoren: pmueller, SE - Design and Construction

llllllll
Erstie
Erstie
Beiträge: 19
Registriert: 29. Okt 2017 21:47

2-PL-Design-Style Slide 29

Beitrag von llllllll » 6. Jul 2018 10:29

Hello,

is there some point to override used in:

Code: Alles auswählen

override def eat(food: this.SuitableFood) : Unit = {}
Maybe I am missing something but the method to be overridden is within an abstract class an has no body whatsoever. So I couldnt figure out why a class inheriting the abstract class should override the method eat when by default you are forced to create an implementation. Thank you.

eichberg
Moderator
Moderator
Beiträge: 448
Registriert: 25. Sep 2007 12:12
Kontaktdaten:

Re: 2-PL-Design-Style Slide 29

Beitrag von eichberg » 6. Jul 2018 10:39

Here, "override" is used to get informed by the compiler if the method no longer overrides something. I.e., it is an instance of "defensive programming".

Antworten

Zurück zu „Software Engineering - Design and Construction“