We did DTOs in a traditional MVC app as there was no way to test the Razor markup in the views. Thus, the objects that went there were first cast to Data Transfer Objects (DTOs) and those simpler things would make their ways up to the markup where there wouldn't need to be any logic to make sense of... oh... say, what's the first street address associated with a person. Instead that sort of figure-stuff-out would be flattened ahead of time by casting one object to another in C# where the flattening could be tested. A coworker today convinced me that maybe we shouldn't be trying to revamp the objects that come back from services in an Angular 2 app and especially so given that the components in Angular 2 are testable. I can see things from his angle. Whenever a new property is added to what comes back from the service all of the mapping logic would need love. Why not skip the mapping logic if you can? One exception might if you are to hide properties from users of certain non-administrative roles. You don't want that coming up to the UI in a JSON object as someone who knows what they are doing could fish it out of a browser.
No comments:
Post a Comment