Topic: Help. about "Method Overriding and Final Methods" in 1-on-1 Spring books

  Print this page

1.Help. about "Method Overriding and Final Methods" in 1-on-1 Spring books Copy to clipboard
Posted by: netxray
Posted on: 2004-10-10 22:53

in chapter 4. Part "Coding Standards", section of "Method Overriding and Final Methods" . the Expert 1-on-1 book.

i can't understand this sentence below. who can help me or tanslate it to chinese?

The number of hook methods might otherwise spiral out of control. In this case, we must temper design rigor with practicality. Superclass documentation must scrupulously note at what point subclass methods should call overridden superclass methods.

thanks in advance.

Blush

2.Re:Help. about "Method Overriding and Final Methods" in 1-on-1 Spring books [Re: netxray] Copy to clipboard
Posted by: dorrenchen
Posted on: 2004-10-11 07:34

要不然被叫的方法会多得无法控制。所以呢,我们要对精心的设计加以实用性的改变。超类的文件必须仔细地记录下在什么时候子类应该叫超类中被重写过的方法。

Well, I don't quite agree with the author.

nobody reads documentation, people code whatever is the easiest for them, especially under deadline. One can not rely on documentation to enforce design framework, because people is going to code whatever java compiler allows. If you want to make people to follow your design, then use "abstract" and "final" modifiers abundantly.

3.Re:Help. about "Method Overriding and Final Methods" in 1-on-1 Spring books [Re: netxray] Copy to clipboard
Posted by: floater
Posted on: 2004-10-11 08:43

I think the point is when you override a superclass method, you need to make a judgement whether you need to call super's same method in your method. A note on the super class method would be helpful definitely. (Of course, if the super's method is empty, then there is no need).

4.Re:Help. about "Method Overriding and Final Methods" in 1-on-1 Spring books [Re: netxray] Copy to clipboard
Posted by: netxray
Posted on: 2004-10-11 09:56

多谢两位!!!!

CJSDN的朋友真好 Smile

5.Re:Help. about "Method Overriding and Final Methods" in 1-on-1 Spring books [Re: netxray] Copy to clipboard
Posted by: dorrenchen
Posted on: 2004-10-11 10:33

In methodA(), if you have to remember calling super.methodA(), then I don't think that's a good design.

6.Re:Help. about "Method Overriding and Final Methods" in 1-on-1 Spring books [Re: netxray] Copy to clipboard
Posted by: floater
Posted on: 2004-10-11 11:05

when you override some method, if the super's method does something for you already, you may think about whether you want to call it in your overridden method. So I think this is a valid scenario.

But your point is absolutely right, especially when there are callbacks which breaks the logic flow.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923