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

  • Nous avons eu la chance de participer à la conférence Lean Kanban France, les 5 et 6 novembre. Cette conférence de 170 participants a présenté un programme...
    12 hours ago
  • With the article "Structuring Complex JavaFX 8 Applications for Productivity" I tried to answer as many Java FX / afterburner questions, as only possible...
    1 day 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