what reasons are there to use interfaces (Java EE or Spring and JPA)

后端 未结 3 1675
深忆病人
深忆病人 2020-12-08 12:14

Most of the J2EE(Spring and JPA) classes are designed with interfaces. Except for inheritance, are there any technical reasons for this? Like dynamic proxy

3条回答
  •  独厮守ぢ
    2020-12-08 13:02

    1. Interfaces for one are contracts as I see them . For example , a set of software engineers(Implementation classes) may have a specific contract with a company(Interface) . The company may choose to switch between the engineers from time to time based on the project needs . Since they come under the same contract and follow the same rules , switching is easier than bringing in a resource from outside (writing a new class) every time the project needs change . You just have to change the configurations to switch the implementation classes .

    2. Interfaces are clean and is a one point access to the rules which the classes implement .

    Links

    1. spring and interfaces
    2. What does it mean to "program to an interface"?
    3. http://www.artima.com/lejava/articles/designprinciples.html

提交回复
热议问题