V
Vincent RICHOMME
Hi,
I would like your opinion about the following subject :
I have a class called CBackupSimContact that is used to copy contact
from a SIM card to the phone memory.
I have another class called CBackupDialog that is supposed to display
copy progress.
So very basically I have the following
class CBackupSimContact
{
public:
void CopyContact()
{
for (int i = 0; i < NumContacts; i++)
{
SendMessage(CONTACT_ADDED); // BAAADDD because using windows
specific mechanism
}
}
};
// MFC MACROS (BAD)
ON_MESSAGE( CONTACT_ADDED, &CBackupDialog::OnContactAdded)
class CBackupDialog
{
public:
CBackupDialog::CBackupDialog ()
{
pBackupMgr = new CBackupSimContact();
}
protected:
void OnContactAdded()
{
ProgressBar.StepIt(); // move progress bar
}
private:
ProgressBar m_ProgressBar;
CBackupSimContact* m_pBackupMgr;
};
So it's a very simple case a class doing some operations and another
that receives notifications.
For now notifications is done by a windows specific mechanism called
message and I am not satisfied with this.
What I would like to know is how could I do it in a more OO way.
I have thought of an observer pattern but don't you think it's a bit
heavy for this simple task?
I am all eyes.
I would like your opinion about the following subject :
I have a class called CBackupSimContact that is used to copy contact
from a SIM card to the phone memory.
I have another class called CBackupDialog that is supposed to display
copy progress.
So very basically I have the following
class CBackupSimContact
{
public:
void CopyContact()
{
for (int i = 0; i < NumContacts; i++)
{
SendMessage(CONTACT_ADDED); // BAAADDD because using windows
specific mechanism
}
}
};
// MFC MACROS (BAD)
ON_MESSAGE( CONTACT_ADDED, &CBackupDialog::OnContactAdded)
class CBackupDialog
{
public:
CBackupDialog::CBackupDialog ()
{
pBackupMgr = new CBackupSimContact();
}
protected:
void OnContactAdded()
{
ProgressBar.StepIt(); // move progress bar
}
private:
ProgressBar m_ProgressBar;
CBackupSimContact* m_pBackupMgr;
};
So it's a very simple case a class doing some operations and another
that receives notifications.
For now notifications is done by a windows specific mechanism called
message and I am not satisfied with this.
What I would like to know is how could I do it in a more OO way.
I have thought of an observer pattern but don't you think it's a bit
heavy for this simple task?
I am all eyes.