Pregunta

Is it OK to use the constructor to set properties for a value object class or must I use dot notation and set each one, one-by-one?

I recently read an article that was saying I should do it one-by-one as value objects should only contain properties and went on to say using the constructor is not OK (best-practice wise).

Code:
("not OK")

var employee=new Employee(firstName,lastName,age);

("OK")

var employee=new Employee();
employee.firstName=firstName;
employee.lastName=lastName;
employee.age=age;

What's your take on this?

Thank you.

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top