Is there a way to implement a Data Transfer Object (DTO)?
In my backend code, I have clearly defined domains such as the Client class:
class Client {
protected $firstName;
protected $lastName;
}
This class contains specific properties that I want to mirror in the frontend. I need to ensure that any object passed to a function is an instance of Client
so I can access its properties.
Furthermore, is structuring an AngularJS (1.5.9) application this way recommended? Will it impact performance negatively?
P.S. Here's an example of what I want on the frontend:
function someFunc(client) {
if (!(client instanceof Client)) {
// handle error
}
// Now I can safely reference client.firstName or client.lastName without encountering undefined values for these required properties.
}
Thank you!