Monday, January 28, 2013

Interface use should remain as concept or general rule ??

Use of the interface as general rule?

After years of JEE development I've seen different release of JEE specification.

Using interface every where was a development best practice.So every service should implement and interface:)

Service service = new ServiceImpl();

But strange, the last specification on the JEE does not heavily rely on the use of interface (the famous local and remote inteface of ejb 1.x, ejb2.x...ejb3.0)?

With EJB 3.0 the use of the interfaces were mandatory (local and remote interface) . But with the latest specification it was no more the case(the declaration of a stateless bean).

  • EJB 3.1

@Statelesspublic class CrudService{
 Even with the dependency injection, no need (for any class) to implement an interface to be usable within the CDI context.

Do we still need to do it? 

But, do we still need to use it systematically within standard jee project (normal jee project).


  • it double the number of the artifact and significantly increase the complexity 
  • it is  absolutely not funny to read javadoc twice
  • the navigation within the IDE is less fluent

But how should this remain used?

The use of interface should remain as concept and not as general rule (systematic) for any service, business component.. within the project:

  • the strategy pattern : several implementation of a strategy or an algorithm(failure strategy, success strategy..)
  • within the case of layer abstraction (separation)
  • within the framework development project: api design and intensive need of abstraction..


Sandeep Bhandari said...

Completely agree with you. By doing so, Oracle is moving away from the golden SOLID OOP principles.

Sandeep Bhandari said...
This comment has been removed by the author.

My favorites blogs

  • Questions for the 16th at July, 6th 2015 at 6.PM. CET: (no reqistrations, no obligations, just ask que...
    2 days ago
  • La revue de presse hebdomadaire des technologies Big Data, Cloud et Web, architectures Java et mobilité dans des environnements agiles, proposée par Xebi...
    3 days ago
  • A previous post introduced some features of using Scala with Vert.x. This post covers how to publish Rest web services in an elegant and simple fashio...
    2 years ago