This is a question more about how to build a c++ application than it is about c++, per se
I’m building an application that was envisioned as a Graphical application, but the specifics of the implementation require a great deal of abstract functionality to facilitate the interface, such as reading lists of objects from files, web resources, etc. I have figured out how to implement this functionality without much difficulty, but I have no good way to test it. Specifically, I’ve begun the implementation of the graphical environment, but it is not yet ready to work with the lower-level functionality.
I have also built a good deal of what I want the lower layer to do, but it is as-yet untested. all of this code resides in a single folder and is stored in a version control system with regular commits.
I’m relatively new to writing anything functional in C++ having only worked on class projects up to this point, but I have written a good number of programs, of various types, in PHP.
If this were a PHP project, it seems it would be simple to test any functionality:
- I would simply begin by implementing it interactively
- codify it into a small file
- write some code that used the functionality
- build it into a function
- import that function into my larger body of code.
This seems like a really awkward way to do the same with C++. Have I got it all backwards, how do you solve small isolated problems, in your compiled programs and import them into your projects; is there a workflow that you find helpful.
I guess this would be the general tactic for any OO project.
First determine the main components and make sure you have a very thorough understanding of what everything is responsible for.
Write out the interface for each component, and check (logically) to see that it fits your problem.
Implement each module.
As far as testing is concerned make tester modules (stubs): for example make a class that will send input to the GUI mimicking the input that would be sent by the actual component. Since you have a clear idea of the interface, how this result was produced would be irrelevant.
Repeat this process for each component in your system and then put them together.
Hope it helps