-1
http://code.google.com/p/jslibs/wiki/JavascriptTips 사이트에서 Javascript
팁을 배우고 있습니다.여기 팩토리 방법 패턴을 사용하면 어떤 이점이 있습니까
나는 Factory method pattern
에 대해 보러 왔습니다. 그들은 다음과 같은 예를
Complex = new function() {
function Complex(a, b) {
// ...
}
this.fromCartesian = function(real, mag) {
return new Complex(real, imag);
}
this.fromPolar = function(rho, theta) {
return new Complex(rho * Math.cos(theta), rho * Math.sin(theta));
}
}
var c = Complex.fromPolar(1, Math.pi); // Same as fromCartesian(-1, 0);
을 표시하지만 실제로는 Factory method pattern
로 불리는 이유 같아요 수 없습니다. 나는 이것을 Factory method pattern
에 대해 알고 싶습니다. 특히 이것을 정확히 사용하는 방법을 알고 싶을 때 유용합니다.
@IanAtkin, 당신은 어떻게 http://c2.com/cgi-bin/wiki?FactoryMethodPattern에 대한'공장 방법 Pattern' – User1674987
@universal에 대해 알 수있는 OP 도움이되지 않습니다 제공하는 링크? 그것은 내가 FMP에 대해 알아야 할 모든 것을 말해 준다. –