I接口
public interface XxxService
主要写方法签名,表达“能做什么”。不能直接 new。
阅读 Java 服务代码时,先找契约,再找实现,最后找谁在调用。
public interface XxxService
主要写方法签名,表达“能做什么”。不能直接 new。
class XxxServiceImpl implements XxxService
写方法体,表达“具体怎么做”。通常使用 @Service 交给 Spring 管理。
I 前缀和 Impl 后缀都是团队命名习惯,不是 Java 强制规则。
因此 ICargoContractInsureService 和 InsureService 都可能是接口;最终要看声明中是否使用 interface。
配套课程:用 DTS 投保代码读懂接口与实现