Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Interface for c++ program

Status
Not open for further replies.

dd007

Technical User
Jan 7, 2003
7
US
I am developing a project programmed in c++ to run from a command prompt. A simple text based menu will be used to change parameters before running. My question, how hard will it be to later add a GUI using visual c++ to my existing code? Any tips or tricks for importing my c++ classes to vc++. I am new to vc++.

Thx
 
My advise is to start it using GUI. Is much simplier and better. The only unadvantage is a little difficult to start.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
It all depends on how you design your application.

When creating new apps, I usually develop all logic in a console app and test it out before I move it into a GUI app.

Of course I cant reuse the user interaction, but that is not part of the application's core logic anyway. However my code should be able to handle calls from a console as well as from a GUI (it actually doesn't know anything about who's calling anyway)

I make it a point of not being dependant on either GUI or console specific functionality, and I always let the console app project live inside the .dsw (as a "sibling" to the GUI app) even after the GUI app has been created. I use it for unit testing to ensure that I don't break anything when I alter the code...

With proper design you can move everything into a GUI application (except perhaps the .cpp with the main() function) without almost any modification.
Just make sure you
1) Are not dependant on the console application. Ie no autogenerated #include "theMainApp.h".
2) Are not dependant on the console. Ie no std::cout and stuff, except in the main.cpp.
3) Don't have any application logic in the main.cpp, but only in your own classes.


So...back to your question:
>My question, how hard will it be to later add a GUI using visual c++ to my existing code?

You shouldn't attept to "add" it to your code, you should create an entire new application, designed so it can be transferred to GUI with a minimum of effort.



/Per

if (typos) cout << &quot;My fingers are faster than my brain. Sorry for the typos.&quot;;
 
Clarification:
>3) Don't have any application logic in the main.cpp, but only in your own classes.

I always have one class per .h/.cpp file, ie the above could also be read as

3) Don't have any application logic in the main.cpp, but only in your own application-specific .h/.cpp.

/Per

if (typos) cout << &quot;My fingers are faster than my brain. Sorry for the typos.&quot;;
 
A good Object Oriented Design of the original project will make transitioning the original artifacts to a GUI interface simple. Look at Software Patterns like MVC (Model View Controller), designs like these enable the user interface to be replaced with minimal effort due design principles like isolation.

-pete
 
Thanks for everyones input. I will keep this in mind when I am programming the project.

Thx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top