Having the option of customized classes but a unified class name

后端 未结 5 1974
甜味超标
甜味超标 2021-01-02 21:35

Suppose you are building a web application that is going to be a packaged product one day, one that users will want to be able to extend and customize.

It comes with

5条回答
  •  再見小時候
    2021-01-02 21:54

    I'd go with using the constructor of the core class to determine the user class to load, and then implement a factory method in the core class to generate instances of the user class. By making the constructor of the user class protected, and having the user class extend the core class you can be sure that code elsewhere cannot instantiate the user class.

    C.

提交回复
热议问题