java对外接口 入参实体命名,Java接口命名约定

关于Java接口命名,存在不同的观点。一种是在接口名前加'I',如IDocumentMappingService,另一种是在实现类名后加'Impl'。然而,一些开发者认为这两种方式都不理想,主张接口名称应明确其契约,实现类则说明如何实现契约。文章讨论了通用的接口命名,如EmployeeRepository implements Repository,或使用'Default'或'Support'作为实现类前缀,例如DefaultEmployeeRepository。最后指出,重要的是保持命名一致性,并提供了一些具体的命名建议。
摘要由CSDN通过智能技术生成

I work on a Java web-app that uses Spring for dependency injection and JMock for mocking out these dependencies in our unit tests.

Currently our team is at a point were we have a few different opinions in terms of how to name certain interfaces that we use. We have no issue with naming the interfaces in our domain that have multiple implementations, that is simple. However, when it comes to interfaces for which we only have one implementation and intend on only having one implementation in the future, we have hit a snag.

The reason that we have such interfaces is purely for mocking, for example, we have services and repositories that we mock out in our unit tests and these services will be named "DocumentMappingService" or for repositories "EmployeeRepository". At the moment some of the guys just prefix the associated interface name with an "I", i.e. "IDocument

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值