Solved

How to design a VC++/MFC database application

Posted on 1998-10-29
7
213 Views
Last Modified: 2012-05-04
I'm trying to design a telecommunications network planning application. The user will enter network data through various dialogs and, in response to clicking Save on the File menu, it will be stored in a MS Access database. In response to a menu pick, algorithms to perform some analysis on the network will be invoked, and will run as threads. The output will also be stored in database tables, and displayed through reports.
The main application will be built as an AppWizard exe.
I plan on creating an MFC extension DLL containing a class derived from CRecordset for each table in the database. (I'd like to have them in a DLL so that other applications could also use them.) Another DLL will contain the functions to perform the analysis. Only one of these functions will be directly invoked from the main application and it will be a thread function.
My question is, how do I set this up so that both the main application and the thread function in the DLL can access the data? That is, I'd like the CRecordset objects to be created in the main application but available to the thread function. I'm not sure whether the CDatabase object and CRecordset objects should be members of the view or document class in the main application, or should they be defined as globals in the app class.
0
Comment
Question by:ajm411
7 Comments
 

Author Comment

by:ajm411
Comment Utility
Edited text of question
0
 
LVL 8

Expert Comment

by:MaDdUCK
Comment Utility
pass pointers between the two...
0
 
LVL 3

Expert Comment

by:danny_pav
Comment Utility
don't forget to synchronize the use
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:altena
Comment Utility
This sounds like a real bad idea to me....

Ill explain:
The document/view framework is just a way to look ar data.
It is a bad idea to have all sorts of threads running aroung
accessing this data, (recordsets or something else)
The synchronisation problems will kill the app.

The idea to componentize the app is a good one, but your
components should be based on "objects" in stead of tables.

Think this one over real good, separate the DB-work from the C++ work. and build a good object model FIRST.

Good Luck
0
 

Author Comment

by:ajm411
Comment Utility
While Altena did a good job of explaining why the design assumption I made was a bad one, not much was offered as far as an alternative.

I had considered the suggestion to use my own objects rather than CRecordset derived objects in the thread function. If I do this, I'm still not sure where to define these objects so that they are accessible by:
1.) the doc class of my main app, where they will be populated from the CRecordset derived objects (the doc class will own the CRecordset derived objects) and
2.) the thread function (or even just a regular function) in a separate DLL containing the algorithms.
0
 
LVL 1

Accepted Solution

by:
TheGrinch earned 100 total points
Comment Utility
The CRecordset classes should go in your Document class, and should all share a single database connection. That is, create a CDatabase object and use it when constructing the CRecordsets.

The thread should create a different database connection, and instantiate a separate set of CRecordset objects using this connection.

There is no advantage to having a single set of CRecordsets. They will be defined only once, but instantiated twice. Sharing a single set between the main App and the thread introduces many complexities but offers no gain.

Your design is reasonable.
0
 
LVL 1

Expert Comment

by:TheGrinch
Comment Utility
No comment -- I just forgot to check the notify box.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now