Naming convention for non-virtual and abstract methods

前端 未结 8 1141
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 02:49

I frequently find myself creating classes which use this form (A):

abstract class Animal {
  public void Walk() {
    // TODO: do something before walking

    /         


        
8条回答
  •  南笙
    南笙 (楼主)
    2021-02-05 03:13

    Btw, is there a name for this design pattern?

    Your first example uses aspects of the Template Method pattern and is similar to what Herb Sutter calls the "Non-virtual Interface Idiom":

    • http://www.gotw.ca/publications/mill18.htm

提交回复
热议问题