in reply to (tye)Re: new() is just a constructor by convention right?
in thread new() is just a constructor by convention right?

There's a difference between a "constructor" method, which gives you back a newly created (and possibly initialized) instance of a named class, and a "factory" method, which you invoke on an instance of one class to get back a newly created (and possibly initialized) instance of a different class.

The difference is in whether or not you need to know the class name. Factory methods "hide" that need, which is a Very Good Thing when you're building class hierarchies that other might extend.

DBI's prepare is a factory method, not a constructor.

  • Comment on (dws)Re: (tye)Re: new() is just a constructor by convention right?
  • Download Code