我在某些代码上运行pylint,并收到错误"公共方法太少(0/2)".这条消息是什么意思?该pylint的文档也没有什么帮助:
当类有太少的公共方法时使用,所以一定要确保它真的值得.
我一直在阅读有关在JS中进行OOP的不同方法.
Douglas Crockford有一种有趣的方法,他似乎根本不使用授权.相反,对我而言,他似乎纯粹利用对象连接作为他的继承机制,但是我很难说出最新情况,我希望有人可以提供帮助.
以下是克罗克福德在其中一次会谈中提出的一个例子.
function constructor(spec) {
let {member} = spec,
{other} = other_constructor(spec),
method = function () {
// accesses member, other, method, spec
};
return Object.freeze({
method,
other
});
}
Run Code Online (Sandbox Code Playgroud)
以下是一个要点的例子
function dog(spec) {
var { name, breed } = spec,
{ say } = talker({ name }),
bark = function () {
if ( breed === 'chiuaua' ) {
say( 'Yiff!' );
} else if ( breed === 'labrador' ) {
say('Rwoooooffff!');
}
};
return …Run Code Online (Sandbox Code Playgroud)