Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB OOAD??  RSS feed

 
Ernest Lee
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the book Mastering EJB II, it states that a OO system should contains 2 types of components.
1. Application logic component (action)
2. Persistant data component (data)
that really confuses me because in OO, aren't we suppose to have behavior+data in the same object? is that because of the fact that we are using EJB.. we have to separate them in Session bean and entity bean???
pls clarify.
 
Ralf Allar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ernest,
the separation between session and entity bean is no break with OO. Okay, let me explain it...
A session bean should represent the business logic, i.e. createEmployee, deleteEmployee, etc.
The entity bean represents the data. The employee itself. It's only methods should be the getter/setter ones.
So, the data is clearly and cleanly seperated from business logic and that's no affront to OOA/D.
Have fun,
Ralf
 
Dave Landers
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An Entity bean can have behavior (business methods other than get/set), but they should be methods appropriate for a single Entity instance.
An Entity bean (in EJB 2.0) can also have Home methods that are appropriate for acting on Entities of that "type" (not instance-specific), but should generally not deal with entities of other types.
In a system, you are most likely dealing with several Entity (data) types. For example you may have Employee, Customer, Manager, Address, Product, etc. The Application Logic generally deals with multiple entities - actions, interactions, relationships, etc.
If you think about MVC, the entities are the Model (data), the session beans are usually used to implement a Controler, and the View is the user interface (whatever that is - outside EJB usually).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!