I want to send back formatted messages from my domain, For example things like:
(Bear with me this is not a real example, its just to illustrate my point)
Hello Mr user, you cannot perform that
task because:
- reason 1
- reason 2
- reason 3
I also want to show colors.
Right now I am sending it from the domain already marked up with HTML.
This seems wrong to me. Because if I want to re-use that domain with a different front end, that may not be HTML aware, it will require different formatting and/or markup.
How can I design this so that my messages from the domain intended to be displayed on the user’s screen can be markup ignorant?
For something really simple you could do something like this:
Or you could use the decorator pattern and create a message that way. You could then create a
DomainMessageWriterthat takes a domain message and spits out the right markup (ieHtmlDomainMessageWriter,RtfDomainMessageWriteretc).HTH