Value objects and DTOs

👁 100 SzerzƑ: Fejes Dávid Frissítette: Fejes Dávid Frissítve:
#PHP

https://www.conroyp.com/articles/building-resilient-code-harnessing-the-power-of-value-objects

DTOs are concerned only with the data types which appear in the data, rather than the business logic involved. Value objects, on the other hand, need to care about the specifics of the business domain, not just the types. They'll contain the logic which ensures that a string is an email address, for example, complaining loudly if not. Value objects also tend to be immutable. class EmployeeDTO { public function __construct( private string $name, private Phone $phone, private Email $email, private Salary $salary, .... ) }
HozzĂĄszĂłlĂĄsok
0 db
HozzĂĄszĂłlĂĄshoz jelentkezz be.
Még nincs hozzåszólås.