How do I initialize classes with lots of fields in an elegant way?

You can either use a constructor or a builder pattern or a variation of the builder pattern to fix the problem of having too many fields in your initialization step. I’m going to extend your example a bit to prove my point of why these options are useful. Understanding your example: Lets say an Offer … Read more

JavaScript: using constructor without operator ‘new’

In general, if something is documented as being a constructor, use new with it. But in this case, RegExp has a defined “factory” behavior for the situation where you’ve called it as a function instead. See Section 15.10.3 of the ECMAScript (JavaScript) specification (that links to the outgoing spec; the section number is the same … Read more

If two objects are declared in a single line, in which order are they constructed?

From 8 Declarators [dcl.decl] 3: Each init-declarator in a declaration is analyzed separately as if it was in a declaration by itself. It goes on to say A declaration with several declarators is usually equivalent to the corresponding sequence of declarations each with a single declarator. That is T D1, D2, … Dn; is usually … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)