Pergunta

I have a model "news item" which contains text, image etc to display as latest news on several pages in a website. This "news item" can also be posted to Twitter or Facebook. Is it clean to implement a method post inside the news item model and inject the different post implementations as a strategy? Or is it better to have a separate application service for this?

Thanks

Foi útil?

Solução

It doesn't belong in the model; an application service is more appropriate.

Create an interface, IPostService, say, with a method PostItem. Then create separate concrete implementations for Twitter and Facebook that implement IPostService.

Outras dicas

I would put them in so called ModelCommands.

So for every unit of change you want to make to the domain model wrap them up in a model command which are then executed seperately or in a chain. This also allows to to incoorporate the Unit of Work pattern which makes transactions persitence ignorant.

Have a look at: http://msdn.microsoft.com/en-us/magazine/dd882510.aspx

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top