[Passwordsafe-devel] Design Issues - Env class & Storage class
Popular easy-to-use and secure password manager
Brought to you by:
ronys
From: James C. <Ja...@No...> - 2002-05-30 03:50:49
|
OK, How 'bout we discuss some real design issues. Scanning the source code, it looks a lot like it was designed by a C programmer who learned C++ by running VC++'s ClassWizard. Nearly every class is derived from CDialog. The two main one not derived from CDialog (BlowFish & CItemData) have serious problems (next email). First, I suggest we create a global singleton call Env or Config, which manages all user options. Every choice should be exposed as a property, and it will be completely responsible for the persistence of them. That way we can isolate the means of persistence (which presumably is platform dependant: Registry, INI file, a file in the /etc directory or whatever) from the rest of the code. Presently, we have code like this: CConfirmDeleteDlg::CConfirmDeleteDlg(CWnd* pParent) : CDialog(CConfirmDeleteDlg::IDD, pParent) { m_dontaskquestion = app.GetProfileInt("", "deletequestion", FALSE); } // : // : CConfirmDeleteDlg deleteDlg(this); if (deleteDlg.m_dontaskquestion == FALSE) { int rc = deleteDlg.DoModal(); if (rc == IDOK) After this change, we'll have: CConfirmDeleteDlg::CConfirmDeleteDlg(CWnd* pParent) : CDialog(CConfirmDeleteDlg::IDD, pParent) { } // : // : if (Env.confirm_deletion()) { CConfirmDeleteDlg deleteDlg(this); int rc = deleteDlg.DoModal(); if (rc == IDOK) Note also, that the sense of the flag has been reverse to the positive. The current way, TRUE indicates a negative, so here, FALSE means "Yes, do it". --------------------------------- The next class we should define I'll simply call "Storage". It's will be completely in charge of reading & writing the PasswordDb. Basically, it takes a filename, and returns a vector<CItmeData> (It also takes the vector and writes it out). Again this is to let us separate the platform specific areas for the generic data (For the PocketPC, I've been thinking about using the systems internal database instead of a flat file). Truth, James Curran |