English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

原文如下:


Understand data dependencies
Descendant classes in a hierarchy are
rarely isolated from their parents. In many
cases, a descendant’s methods either directly
change an ancestor’s state or call inherited
methods that directly change state. Never-
theless, the descendant class’s designer must
understand these state space interactions.
Failure to properly ensure the state-depen-
dent behavior inherited from an ancestor
could introduce faults and behavior anom-
alies. Ideally, the descendant’s designer
would never need to understand such parent
details. Unfortunately, this rarely happens,
particularly when the descendant class re-
fines a parent’s behavior. Even extending the
descendant to support new behavior can
easily introduce anomalous behavior if the
extension interacts with inherited proper-
ties. Thus, a key to ensuring quality is un-
derstanding each parent’s state-dependent
quality time
Improving the Quality of
Object-Oriented Programs
Roger T. Alexander, Colorado State University
E d i t o r : J e f f r e y Vo a s
I
C i g i t a l
I
v o a s @ c i g i t a l . c o m
Page 2behavior, descendant–parent data depen-
dencies, and the effects of the descendant’s
behavior on the parent’s behavior

2006-12-24 18:07:38 · 1 個解答 · 發問者 Anonymous in 社會與文化 語言

1 個解答

瞭解資料相依性
 在繼承關係中的子類別很少與父類別差異很大。常見的情況是子類別中的方法不是直接改變父系類別的狀態,就是利用繼承下來的方法來改變狀態。儘管如此,在設計子類別時需要瞭解到這些狀態空間的相互關係。如果沒有確保從父系類別繼承而來的狀態相依行為,則有可能會有錯誤或反常的行為發生。最理想的情形是子類別的設計者無需知道父系類別的詳細內容,但很遺憾的,這種機會不太常見,尤其是常子類別是用來改善父類別的行為時。如果在撰寫子類別時在加入了新的行為,但卻牽扯到繼承而來的屬性,很有可能會導致異常行為的發生。因此,要確保品質,最重要的便是瞭解每一個父系類別的相依狀態。

2006-12-25 10:58:59 · answer #1 · answered by ? 7 · 0 0

fedest.com, questions and answers