Home  >  Q&A  >  body text

java - For example, when writing a Service or Dao in Spring MVC, is it best to write an interface implementation?

I see many examples of writing a UserService, and then writing an interface implementation such as UserServiceI. I feel that it is very troublesome to write so many duplicate files for small projects.

習慣沉默習慣沉默2712 days ago494

reply all(1)I'll reply

  • PHP中文网

    PHP中文网2017-05-17 10:04:21

    If it is for self-entertainment, such as a small project that is only used in one place, there is no need to write an interface. Unless it is used in multiple places or called remotely. Interfaces are used to abstract implementations and are not necessary for all scenarios.

    reply
    0
  • Cancelreply