0

I asked this question which was poorly received because it is apparently too broad. What additional narrowing down is required? I removed the vague and/or opinion-based 'best/cleanest/fastest way' parts and instead I specified:

  • 3 specific options for file access
  • At least 1 specific question about each of them
  • That other feedback about each of these issues is welcome

I also realized that the first half of the old question was already covered in another question so I removed that part entirely and focused on the second half.

I have read this but I fail to see what else is missing. I am trying to create a desktop application. I feel the premise of the question is on-topic because saving data is a fundamental part of software development but I need some help asking it in a way that will be well-received. A community member has expressed approval at the current state of the question in light of the recent edits, but how can I get the question reopened?

Update: The question has since been reopened. I have since asked a followup question about getting answers instead of getting deleted by the Roomba.

2 Answers 2

2

Your question has a few issues. You asked

What is the cleanest and fastest way to handle data for a desktop application in C or C++?

Well, "handle data" is an incredibly broad description, in some sense "handling data" is all what each computer program is about. The question's body then mentions you are thinking about "saving user settings or saved games or browser history", which is a lot more specific, since now it is clear you are talking about saving and loading data, probably user specific data, to the file system which reflects the application state to make it available when the application gets restarted. I would usually recommend to do what user253751 already told you in a comment: just ask for saving user application settings (and if you have some data you don't like to call "settings", just check if you can transfer solutions to that case). But beware, if you would really do so, chances are high the question would be closed as a duplicate, see below.

The idea of a "generally fastest" approach shows a very wrong expectation. There is not "fastest" approach" outside the context of a real, specific application. How much time loading or saving of settings data takes is generally dependent on the amount of data which has to loaded and saved, and on the "portions" in which the data has to be loaded or saved. Both is totally dependent on the specific case and cannot be answered sensibly out of context. Moreover, for many applications, the performance of loading or saving user settings or other application data isn't the bottleneck worth to be optimized.

Also, there is no "generally cleanest" approach. You can evaluate "cleanlyness" for a specific program or function, but one has to see the function which saves and load the specific data and review it to tell you if there is a more "cleaner" way.

What remains in your question is a portable way of finding a base directory for storing application-specific data. The answer to this was already given in the final comment by GrandmasterB:

C++ GUI frameworks like QT certainly may offer a more universal way to get the right directory, but otherwise you have to query the OS yourself. 10 lines of code and you should be good to go.

You will find more specifics how to do this in this older SE question (for Windows, you may ignore the Registry part in the accepted answer and focus on the %APPDATA% solution mentioned here). Note this question was from 2010, where the scope of this site was much broader. Today, it is likely the wording "Best way to save application settings" could lead to quick closage by the community with "needs more focus" as well.

5
  • Do you think it is worth trying to save my question at this point? If I edit to specify that I am referring specifically to user-specific application settings, etc? And if I narrow the scope of the question to zap the first part about querying the home directory and instead ask specifically about the 3 ways I listed to access files? May 4, 2023 at 13:52
  • @user16217248: it seems you already tried to save it, I see a lot of improvements now (and your question got a reopening vote from someone else). However, you are still mixing the question for "best performance" with other, unrelated aspects. Asking for performance of reading and writing application setting is totally meaningless out of context and even in most real world case negligible.
    – Doc Brown
    May 4, 2023 at 20:01
  • ... if it is worth trying it, however, is something you have to decide by yourself, taking into account how important it is for you to get an answer. At least you may have learned how to write better questions for this site. But don't put your expectations on getting the question reopened too high, our community here is sometimes a little bit hesitant to reopen such questions, especially when the question is already closed for for more than two weeks,
    – Doc Brown
    May 4, 2023 at 20:06
  • I made another edit, how does the question look now? May 7, 2023 at 18:01
  • 2
    Looks better now. Now you can only wait to see how the community will think about it.
    – Doc Brown
    May 7, 2023 at 19:56
1

You could probably go one of two ways with this from my understanding of the question. You could ask a distinct question for a single operating system regarding which particular method for storing user preferences would be best for portability to other operating systems. I think this will help focus the question a bit, since the most portable or generic implementation might be different for each operating system or portability may not even be possible depending on constraints of the specific operating systems.

Sometimes certain questions are more likely to be closed if the question itself is fundamentally unanswerable or illogical on its face. User setting conventions are typically defined BY operating system, so portability is meaningless as a quality attribute here. You might as well ask, "What is the best shade of black present in the color yellow." I am not saying that is necessarily the case for your question but it reads that way to me.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .