I'm building a REST API that exposes data as XML. I've got a whole bunch of domain classes in my domain layer that are intended for consumption by both the service layer behind the API, and the client API that we will be providing to customers. (Customers do have the option of interacting directly with the REST API, but the client API simplifies things). I want to keep my domain classes clean of any data persistence logic, but I'm strugling with trying to figure out if it's OK for the domain classes to implement IXmlSerializable to help simplify the process of serializing the data that is exposed through and retrieved from the API. I started out thinking that I'd keep the domain classes free of any serialization logic and instead decorate them with serialization behaviors, e.g. wrap the domain object inside of an object that handles the serialization. Am I making things more complicated than they need to be? Any thoughts on how I should approach this? Thanks!
Should domain objects implement IXmlSerializable?
458 Views Asked by csano At
1
There are 1 best solutions below
Related Questions in C#
- Passing arguments to main in C using Eclipse
- kernel module does not print packet info
- error C2016 (C requires that a struct or union has at least one member) and structs typedefs
- Drawing with ncurses, sockets and fork
- How to catch delay-import dll errors (missing dll or symbol) in MinGW(-w64)?
- Configured TTL for A record(s) backing CNAME records
- Allocating memory for pointers inside structures in functions
- Finding articulation point of undirected graph by DFS
- C first fgets() is being skipped while the second runs
- C std library don't appear to be linked in object file
- gcc static library compilation
- How to do a case-insensitive string comparison?
- C programming: Create and write 2D array of files as function
- How to read a file then store to array and then print?
- Function timeouts in C and thread
Related Questions in DOMAIN-DRIVEN-DESIGN
- Should i take DateTime.Now from Database?
- How to avoid anemic data model? Can repositories be injected into entities?
- Defining aggregate roots when invariants exist within a list
- Is it okay to create a DTO counterpart of a table in a database assuming its persistent ignorant domain model and the DTO is in the repository?
- Should i do authorization on my Domain Services?
- Should i validate if related entity exists before insert?
- Using framework event dispatcher to raise domain event
- How to temporarily circumvent domain object's creation contracts when restoring application from backup?
- Domain Driven Design for Rails App: Implementing a service in a basic example
- DDD\CQRS\Event Sourcing and request historical data
- Is it possible to properly use DDD with all building blocks in monolith application?
- Replicate property size from domain to fluent api and viewmodel
- DDD aware of existance of an entity outside the context?
- Is there a way to access a private property in a where clause?
- Should I unite business domains into one business layer
Related Questions in IXMLSERIALIZABLE
- How to implement IXmlSerializable correctly for a ICollection<T> where T is an abstract class?
- Dynamic XmlSerializer that identifies the object type from the xml-serialization?
- Using LINQ to XML to implement IXmlSerializable
- Getting Property's Custom Attributes during Serialization
- IList and custom XML Serialization of nested objects
- XmlSerialization of IXmlSerializable array
- OmitXmlDeclaration in XmlWriter and implementing IXmlSerializable
- IXmlSerializable with valid XmlSchema (XMLSchema:schema' element is not declared..)
- Should domain objects implement IXmlSerializable?
- Exporting WSDL/XSD schemas for data contract types with IXmlSerializable
- Serialize type into XML from .NET
- IXmlSerializable. XmlWriter. How to change root element?
- How to do xml serilization for derived entity
- How can I control the root element namespace and name when serializing an IXmlSerializable object with the data contract serializer?
- How to add namespace prefix for IXmlSerializable type
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Domain classes should be concerned with business logic only, not with persistence or serialization.
You should create a set of Data Transfer Object (DTO) classes, each corresponding to one of the domain classes. These classes would only contain the properties, from the domain classes, that you have decided to expose. This permits the domain classes to have properties which are not exposed through your persistence or serialization layers.
Only the DTO objects would be serialized and deserialized.
You may then find it convenient to create static "translate" methods to translate between the domain and DTO objects.