开发者

Interface programming

Background

A developer on my team has implemented an application which I was reviewing. He has used interfaces everywhere. The app has typical service layer, data layer and POCO objects开发者_JAVA百科 passed from website down to DB.


Assumption

IOC used (through Unity) to inject a runtime concrete Service and Data class. All POCOs have nothing but get and set methods on public properties.


Question

I understand why an interface is used at the Service and Data layer but why would you use interfaces on all POCO objects? Is this overkill?


Do the POCO interfaces serve a purpose? If yes, they may not be overkill. However, if they are not used, they violate the YAGNI principle.

However, on a more general note, I'm beginning to think that properties on interfaces are design smells, as they violate the Law of Demeter.

I recently posted some thoughts on better abstractions.


It looks like your POCOs are used simply as Data Transfer Objects. If that's the case, they're just carrying information, with no behavior. Creating interfaces for them is overkill.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜