Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oop 我怎样才能预防;方法仅调用其他方法“;在我的代码里?_Oop_Architecture_Abstract Class - Fatal编程技术网

Oop 我怎样才能预防;方法仅调用其他方法“;在我的代码里?

Oop 我怎样才能预防;方法仅调用其他方法“;在我的代码里?,oop,architecture,abstract-class,Oop,Architecture,Abstract Class,假设我编写了一个类Authentication,它提供了注册用户和登录用户的方法。 当然,我需要另一个类DB,它将运行实际的数据库语句并检索数据 当在另一个应用程序中导入Authentication以使用它时,我将调用它的方法signUpUser(),该方法将注册一个用户。 现在,这个方法将运行一个与Authentication.signUpUser()相同名称和用途的方法,但实际上是在DB中执行数据库语句 有没有办法阻止这种“类中的方法只调用另一个方法”的方法?我应该阻止这样的包装函数吗?这里

假设我编写了一个类
Authentication
,它提供了注册用户和登录用户的方法。 当然,我需要另一个类
DB
,它将运行实际的数据库语句并检索数据

当在另一个应用程序中导入
Authentication
以使用它时,我将调用它的方法
signUpUser()
,该方法将注册一个用户。 现在,这个方法将运行一个与
Authentication.signUpUser()
相同名称和用途的方法,但实际上是在
DB
中执行数据库语句

有没有办法阻止这种“类中的方法只调用另一个方法”的方法?我应该阻止这样的包装函数吗?这里的好习惯是什么?为什么