Ex 5.2 - InsufficientDocumentation

Moderatoren: pmueller, SE - Design and Construction

0b101101101
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 179
Registriert: 15. Apr 2015 18:24

Ex 5.2 - InsufficientDocumentation

Beitrag von 0b101101101 » 4. Dez 2017 14:53

In the lecture slides it is said that any overridable method must declare use of other overridable methods. However, what about attributes? I believe if a method uses attributes that are modified by overridable methods _or_ can be modified in a subclass, then methods must declare the use of these attributes, too, or else a subclass may simply choose not to modify those attributes in the same way and methods will surprisingly fail.

GS-812
Windoof-User
Windoof-User
Beiträge: 30
Registriert: 25. Apr 2015 12:47

Re: Ex 5.2 - InsufficientDocumentation

Beitrag von GS-812 » 4. Dez 2017 14:58

I see it the other way, overridable methods must explain, which attributes have to update in case you overwrite them.

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

Re: Ex 5.2 - InsufficientDocumentation

Beitrag von eichberg » 4. Dez 2017 15:14

In general, I highly(!!!) recommend to only use private state. However, if you have a non-private instance field you should document the contract (the invariant) related to the field where you define the field. (It may be necessary to update the field in a future subclass in a new method which does not override anything.)

Antworten

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