In floyd's ejb design pattern book, he covers data access command beans as one of the patterns to deal with decoupling the logic/persistence details away from the ejb logic.
In the sample code, the following listing appears: (keep in mind that the InsertEmpCommand inherits from a DataAccessCommand base class)
<code>
InsertEmpCommand cmd = null;
try
{
cmd = new InsertEmpCommand();
cmd.setEmail("[email protected]");
cmd.setName("DN");
cmd.setID(id);
cmd.execute();
}
catch (DataCommandException e)
{...}
</code>
now looking at this, it just makes absolute sense to take this decoupling one step further and use a DTO that extends from a base class that the data access command base would support a setter on.
example
<code>
public abstract class DataAccessCommand
{
...
public abstract void execute() throws DataCommandException;
public abstract void setData(DTOBase dto);
...
}
</code>
this will then reduce the first code snippet to: (EmpDTO would extend DTOBase)
<code>
InsertEmpCommand cmd = null;
try
{
cmd = new InsertEmpCommand();
cmd.setData(empDTO);
cmd.execute();
}
catch (DataCommandException e)
{...}
</code>
thoughts?
-
Using Data Access Command Bean pattern with DTOs (1 messages)
- Posted by: make ship go
- Posted on: March 26 2002 13:39 EST
Threaded Messages (1)
- Using Data Access Command Bean pattern with DTOs by make ship go on March 26 2002 13:42 EST
-
Using Data Access Command Bean pattern with DTOs[ Go to top ]
- Posted by: make ship go
- Posted on: March 26 2002 13:42 EST
- in response to make ship go
I'll move this message to the patterns section - this is more of a design patterns discussion than just an ejb design.