浏览 4083 次
锁定老帖子 主题:PDO优于DAO?
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-09-21
PDO中: public interface Entity{ public interface EntityDBManager{ public void insert(Entity entity); public void save(Entity entity); .........//other method } ..............//other method you want } public class EntityImpl{ private static Entity.EntityDBManager manager = null; public static Entity.EntityDBManager getManager () { return EntityDBManager.manager; } public static void setManager ( Entity.EntityDBManager manager ) { EntityDBManager.manager = manager; } ...... //properties and methods private Object XXX; public void setXXX(){} public XXX getXXX(){return XXX;} } ..... public class EntityDBManagerImpl implements Entity.EntityDBManager{ //implement methos .... .... } DAO 中: (太熟了,省略....) ................................................. //调用中可能是 EntityDBManagerImpl manager = ... Entity entity= new Entity ("name"); etity.setCatManager(manager ); etity.getManager().save(entity); 但在DAO中也可以这样 : //此处的manager不和上处同 EntityDBManagerImpl manager = ... Entity entity = new Entity("name"); EntityDBManagerImpl .save(cat); 是否这样简洁些?! 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |