Conversation
|
Different ways to achieve the same result are generally not good. Also there is the analyse() method with the same signature. |
Named constructors are actually quite common (e.g. here or here). What is wrong with the concept in your opinion?
Maybe this is a matter of taste, but I would rather not have such a method; it makes the state of the object mutable / not fully encapsulated. The method could be private for instance. But this method is there probably because the constructor is expensive as well? In that case, must the parser already be constructed with a user agent string? Is the user agent string actually part of the state of a parser? |
This PR adds two methods which allow a more intuitive way to construct a parser, e.g.:
As a side note: two redundant
instanceoftests are removed. An instance either fails to construct or is already an instance of that class.