views:

144

answers:

2

With the arrival of JEE and EJB 3,

  1. have any of these Core J2EE Patterns become obsolete, or stand deprecated in light of (better) alternatives?

  2. Are there any new patterns that one could use?

Thanks...

+3  A: 

Some patterns such as Session Facade still make sense to me. We still need to take care in the of public interfaces and focus on a Facade is helpful for that purpose. The "Session"-ness tends to be less prominent because we simply can annotate a POJO to get the EJB, but the "Facade"-ness is critical.

Service Locator has been pushed down into the annotation-based injection approach for resource access. So it's not so much unimportant as more nicely wrapped in the JEE framework.

Data Transfer Objects are less widely used, JPA-annotated POJOs, replacing Entity Beans are quite commonly used. There is some debate in this area, in some scenarios DTOs may still be useful, but in simple cases they are probably not needed, and hence there may be less use of related patterns such as Transfer Object Assembler.

djna
+1. You mention four: session facade, service locator, DTO, and TOA. You also say,"Some patterns ... still make sense to me". Does that mean other patterns do not make (so much) sense in the context of JEE to you (or, others)?
Harry
I didn't make much use of Service To Worker or Dispatcher View, so I don't know whether JEE/EJB3 had any impact. Service Locator and DTO I used to use and see them as less necessary now.
djna
Appreciate your answers. I'm still hoping that readers will consider supplementing what you have written so far and make the answer more complete than it is now wrt other patterns. Will hold off marking the answer as final till then. Thanks again...
Harry
DTOs are still usable when unit testing EJBs outside the container. Its typically far easier to mock a DTO than mocking the EntityManager.
Lars Tackmann
@Lars, a touch of devil's advocacy: A JPA object is a POJO with annotation. So in an environment where annotations are not processed, such as outside a container, what difference is there between a JPA-ed bean and a DTO?
djna
+2  A: 

Adam Bien has written an excellent book "Real World Java EE Patterns - Rethinking Best Practices" just about this (i.e. updating J2EE patterns to JEE5/6). You can see a an overview of the changed and updated J2EE patterns in my Summary of the Real World Java EE Patterns.

Jakub Holý
Thanks, that was helpful. I'll check out both.
Harry
Nice reference, and the SOA v DDD discussion there is also interesting
djna