Class A
should define the methods it's going to call (probably as abstract ones, and A should be an abstract class, per Paul Haahr's excellent guide); B
can (in fact to be concrete MUST, if the method are abstract) override those methods. Now, calls to those methods from other methods in A
, when happening in an instance of class B, go to B's overrides.
The overall design pattern is known as Template Method; the methods to be overridden are often called "hook methods", and the method performing the calls, the "organizing method".
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…