472,102 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

architecture design

I have a software architecture question.
I have developped a dialog based application that reads a contactless card
and display its information(name, company, ...).
So basically I have a CDialog (Windows - MFC) and I would like to save the
information read inside a database (SQLite).

SO I have choosen this architecture :

..cpp
CMyDialog:CMyDialog()
{
m_csName = "";
m_csCompany = "";
m_csSerial=0;
m_Status = 0;

}

// called every second
void CMyDialog::OnTimer(UINT nIDEvent)
{
ReadContactlessCard()
DisplayInfo()
ArchiveInDB()
}

CMyDialog::ArchiveInDB
{
m_db.Archive(this); // m_db is an object for a class (CMyDB) used to
handle sqlite database
}

My problem is someone told me that it is not a good design to have a
circular dependency. I mean I declare
a CMyDialog with a CMyDB object and I pass to the CMyDB object a pointer to
the CMyDialog.
How can I do differently?


Jul 22 '05 #1
1 1284
Vince wrote:
My problem is someone told me that it is not a good design to have a
circular dependency. I mean I declare
a CMyDialog with a CMyDB object and I pass to the CMyDB object a pointer to the CMyDialog.
How can I do differently?


Use the technique that /Large Scale C++ Software Design/ calls "escallate
the dependency", and /Agile Software Development: Principles Practices and
Patterns/ calls "Dependency Inversion Principle".

Pass to the CMyDB an abstract base class, containing only those few methods
that the DB layer will use, expressed as pure virtual member functions. Then
CMyDialog inherits this class and implements the methods.

Your friend needs to understand that "isolating changes" is what makes a
design good. Breaking up circular dependencies is a good way to achieve
that, but otherwise if they happen then they happen.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Michael Crawford | last post: by
25 posts views Thread by David Noble | last post: by
6 posts views Thread by V. Jenks | last post: by
4 posts views Thread by Nick Goloborodko | last post: by
6 posts views Thread by Chad Grooms, MCSD >> [VB.NET,C#,ASP.NET] > [VB.NET | last post: by
5 posts views Thread by Ludwig Wittgenstein | last post: by
reply views Thread by Joerg Rech | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.