jive中DbUser和DbUserManager的设计问题

03-03-13 hcxjdon
时间所限,只研究了User, UserManager, DbUser, DbUserManager几个类。DbUserManager管理DbUser,删除的时候用自己的function DeleteUser,但是创建新User的时候要调用DbUser的insertIntoDb.如此设计似乎权责不明,欠妥。DbUser应与数据库中每条记录对应,相关的CRUD操作完全交由DbUserManager完成,这样也便于以后做DAO。各位以为如何?

EricZheng
2003-03-14 09:14
DbUserManager is responsible for creating or remove the DbUser object from memory.

So on Manager layer,it is just DbUserManager to focus on creating or destroying the DbUser object(creatUser()&deleteUser())

On Database layer,it is just DbUser to operate on database.

hcxjdon
2003-03-14 10:03
DbUserManager.deleteUser直接对数据库操作了。再看看源代码。

EricZheng
2003-03-14 14:11
I'm sorry.Now i can't input the chinese.

Yes,you are right.In DbUserManager deleteUser(),it directly operate on the database.It is not a good design.

Suggest to move deleteUser() to DbUser class.

Before this DbUser object was remove from Cache,this method should be invoked.

hcxjdon
2003-03-14 16:59
DbUserManger.users仍有数据库操作。

我的建议是将数据库操作全部移至DbUserManager中,这样方便封装数据库操作,做DAO,方便数据库移植。否则DbUser,DbUserManager都要做DAO,太麻烦。

猜你喜欢
2Go 1 2 下一页