Are EJB Naming Conventions Still Needed?

Since the advent of EJB 3.X I don't use the Local/Remote naming schemes for business interfaces any more. The EJB client is only interested in the functionality and not the distribution or other infrastructural settings. The business interface is therefore just a POJI - without any dependency on the EJB API or infrastructure:

public interface CrudService {

}

The EJB implements the interface and exposes it with the @Local annotation. 

@Stateless
@Local(CrudService.class)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class CrudServiceBean implements CrudService {
}

I actually thinking about getting rid off the suffix Bean as well. It would be much better to emphasize the actualy responsibility and name after it e.g. a JPACrudService. It is already annotated with the @Stateless annotation - so it is obviously a Bean. In my opinion interface naming schemes are unnecessary in general.

Comments:

Exactly. I am not an fan of naming conventions either. Especially when you name your Beans "ServiceBeans" and put them in a "beans" or "services" package. That is so redundant. I think the naming conventions are mainly for the fact that you create classes that you would never create, if the framework didn't force you to. That is where the old OO design rule does not work "if you can't name it, don't write it". :-)

Posted by Thomas on March 18, 2009 at 12:10 AM CET #

Yes, it is needed specially for EJBs. In an application, not all classes (specially service classes) are 'EJBs. So do Programmers don't need to write EJBs if other more simple objects can be used. So it is better to have these differentiated by whether they have the suffix 'bean' or not. In maintenance projects like those maintained by programmers who did not do the original, the 'bean' suffix is a useful indicator. The annotation only helps in the declaration and does not provide a naming indication of its being 'bean' when used away from its 'source', i.e. several classes or modules away....

Posted by Greg on March 19, 2009 at 04:32 PM CET #

I had the same question and hoped to find a answer here. Anyway, I am going without the 'Bean' suffix

Posted by Java Coder on September 12, 2011 at 10:59 PM CEST #

For the focus on EJB development this makes perfectly sense to me.

On a higher level I've my problems with calling everything a service. Nowadays you have services in the presentation layer (e.g. RESTful web services) and in the business layer (e.g EJBs) to name only two kinds of services.

If you have both, e.g. an order service as RESTful web service and an order service as EJB. How would you name these two to distinguish them?

Posted by Frank on October 01, 2014 at 11:06 AM CEST #

Post a Comment:
  • HTML Syntax: NOT allowed
...the last 150 posts
...the last 10 comments
License