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

  • Le prochain meeting du Paris Scala User Group sera le jeudi 21 aout chez Xebia à 19:30. Nous aurons l’honneur d’accueillir David Galichet pour un talk sur ...
    18 hours ago
  • In the interview I said: "The JavaOne is the only conference, which I attend as a speaker" what I meant was: " an attendee". Sorry, but it was lat...
    6 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...
    1 year ago