Questions: On Design By Contract Inheritance Issue..?問題:對設計合同的繼承問題.. ?
Questions for all Design By Contract practitioners -問題的所有設計合同練習者-
If my class ( E ) implements three interfaces (A, B & C) and extends class D, each with its own pre-conditions and post-conditions and some invariants.如果我的班級(五)實行三個接口(一, B及C )和擴展的D類,每個國家都有它自己的先決條件和後條件和一些變量。
Class E also has few pre-conditions and post-conditions and some invariants.一流的電子商務也有幾個先決條件和後條件和一些變量。
Pre-conditions can be weakened.先決條件,可以被削弱。 So presumably it is an OR clause binding all the pre-conditions of A, B, C, D & E. The question is in what order?因此,假設這是一個或第約束力的所有先決條件的甲,乙,丙,丁,與五,問題是在什麼順序?
Post-conditions can be strengthened.後的條件,能不能真正得到加強。
So presumably I should AND all the pre-conditions of A, B, C, D & E. Is that correct?因此,假設我要和所有先決條件的甲,乙,丙,丁& e.是正確的呢?
Nothing I could find aboout inheritance of Invariants.沒有我可以找到aboout繼承變量。 How would you join all the invariants of AE classes?你會如何加入所有變量的愛班? AND clause?和第?
Looking forward for your responses….期待著您的反應… … 。
Filed under提起下 Java Software Java軟件 , , Technology技術 | |
| |
RSS 2.0 2.0 | |
Email this Article電子郵件此文章
You may also like to read您也可以想讀 |




November 11th, 2004 at 5:10 am 2004年11月11日在上午05時10分
The preconditions and postconditions are associated with methods.先決條件和postconditions相關的方法。 Any given method in Java can only be inherited from a single interface or class, so there is no question about ANDing and ORing.任何特定的方法,在Java只能繼承了從單一介面或階級,因此,這是毫無疑問的安定和的ORing 。
When an overriding method modifies the precondition or postcondition of its parent method:當一個壓倒一切的方法修改的前提下postcondition或其母公司的方法:
For preconditions, the parent precondition is tested first.為先決條件,父母的先決條件是測試第一。 If that precondition fails, then the precondition of the current class’s method is tested, and if either succeeds and if the call was from outside the current class then the class invariant is tested.如果先決條件失敗,則前提當前階級的方法是測試,如果成功的話,呼籲外界目前的階層,然後班級不變的是測試。
For postconditions, the parent postcondition is tested first.為postconditions ,母公司postcondition是測試第一。 If that postcondition succeeds, then the postcondition of the current class’s method is tested, and if that succeeds and if the call was from outside of the current class then the class invariant is tested.如果postcondition成功,那麼postcondition對當前階級的方法是測試,如果成功的話,呼籲從外部對當前階級階層則是不變的考驗。
For constructors, however, the rules are different.為建設者,但是,規則是不同的。 Only the precondition is tested on entry, not the class invariant because the point of the constructor is to establish the class invariant.只是前提是測試就進入,而不是階級不變,因為出發點的構造是建立一流的不變。 On exit, the class invariant is tested first, and if that succeeds then the postcondition is tested.關於出口,階級不變的是測試的第一,如果成功的話, postcondition是考驗。 Note: constructors are not inherited, they’re chained; inheritance rules don’t apply.注:建設者是沒有繼承,他們正在串連;繼承的規則並不適用。
The invariant for a class is the combination of its class invariant and the class invariant(s) for its parent class(es).不變一類是結合其一流的不變和階級不變( ) ,其母公司級(安老服務) 。 All invariants must always be true, so the ordering is somewhat irrelevant.所有的變量必須始終真實,所以訂購是有點不相干。 Still, Eiffel specifies the following order: this class’s invariant, then parent invariants, then invariants associated with any methods redefined as attributes (something you can’t do in Java).儘管如此,埃菲爾鐵塔,訂明下列命令:這一類的變量,然後家長不變量,然後變量相關的任何方法,重新界定為屬性(東西你不能這樣做在Java ) 。