Do we still want to map domain objects to POCOs with AutoMapper anymore? What if we just surfaced the objects all the way up through ReST API endpoints to the JavaScript framework (Angular, React, Vue, etc.) and then let the JavaScript framework do any shape-changing that was needed? The only reason not to do so is we are worried about the expense of what is going across the wire. Assuming you can shelve worrying about that optimization until you need it, why not just chill out on it. I've seen some pretty nasty stuff done with AutoMapper and some of it ridiculously redundant. I worked on a project in which objects coming back from the database in the Infrastructure layer were just being mapped one-to-one to identical objects in the Core layer. The only rationale I could gleam was that that way we didn't have to have DataAnnotations attributes (which are Entity Framework agnostic by the way) in the Core classes. This antipattern demanded the maps in the UI layer and the whole caboodle. Ugh, by UI I mean ReST API... that layer, the front door...
No comments:
Post a Comment