Re: Defining a constructor for Element and friends

> On Jan 13, 2015, at 9:25 AM, Domenic Denicola <d@domenic.me> wrote:
> 
> From: Boris Zbarsky [mailto:bzbarsky@mit.edu] 
> 
>> But it also means that user-space code that has to create an HTML element generically now has to go through document.createElement instead of being able to do |new HTMLElement("a")|, right?
> 
> That seems totally fine to me though. The idea of a string-based factory for when you don't know what constructor you want to use has precedent all over software design.

I agree. It's unusual for a constructor of a super class to automatically instantiate an arbitrary subclass based on its arguments. And we usually solve that convenience problem by introducing a factory class/function.

- R. Niwa

Received on Tuesday, 13 January 2015 18:19:06 UTC