Zengin bir etki alanı modeli mantığını yerleştirmek için nerede

2 Cevap php

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?

Teşekkürler

2 Cevap

Bu modelde ait değildir; bir uygulama hizmeti daha uygun olur.

Bir arayüz oluşturmak, IPostService, diyelim ki, bir yöntem ile PostItem. Sonra uygulamak Twitter ve Facebook için ayrı beton uygulamaları oluşturmak IPostService.

Ben sözde ModelCommands onları koymak istiyorsunuz.

Yani etki alanı modeli yapmak istediğiniz değişiklik her birim için daha sonra ayrı ayrı ya da bir zincir içinde yürütülen bir model komutu onları sarın. Bu da cahil persitence işlem yapar Çalışma desen Birimi incoorporate için olanak sağlar.

http://msdn.microsoft.com/en-us/magazine/dd882510.aspx: bir göz