0

Sorry if I'm not clear, I didn't touch the program for almost two weeks.

I have a program that reads XML files:

  • A product list
  • Each product's default settings (if custom is not available)
  • Each product's custom settings

Then it constructs a ProductBase object and ProductSettings from either default or custom XML. Afterwards they form a Product object, which is put into a list, and then a WPF DataGrid is filled with list elements.

I'm using very questionable ways to do all this (I'm a beginner) - I realized I should start over because the code is nigh unreadable, and I'm asking here in case I should take a different route while I'm at it. I'm pretty sure current way will make me suffer later on, as even now it causes me headaches.

I need a way to store products list with a possibility to save each product settings (like "is in delivery", or "do not sell" bools) between sessions. It also should take in consideration that product count might change, but it should keep old settings for products that weren't added/removed.

Is there a standard way to do this? It surely must have been done many times. I'm open for any suggestion.

Edit: The product lists aren't huge (probably no more than 100KB), product settings consist of two booleans per product. It would be helpful if it could be portable, but there is no real need for it. I was thinking about a light database, but I couldn't find anything easy to use. Except Sqlite, but I couldn't figure out how to make it work.

6
  • As it stands, this question is far too broad to be answered. We don't know what constraints or other requirements you have to meet. – BobDalgleish Nov 20 '19 at 13:50
  • @BobDalgleish I'm not sure what else I should provide. The product lists aren't huge (probably no more than 100KB), product settings consist of two booleans per product. It would be helpful if it could be portable, but there is no real need for it. I was thinking about a light database, but I couldn't find anything easy to use. Except Sqlite, but I couldn't figure out how to make it work. – xtl Nov 20 '19 at 14:02
  • do you mean "each product types default setting"? Or do the default and custom settings contain different properties? I'm confused since I do not see any need to store both default and custom settings for each product if only one will be used. – JonasH Nov 22 '19 at 10:18
  • @user104903 All products are considered equal. I want it to act like this, both setting bools should default to false, thus every new product would start with false bools. Otherwise it should use user settings. Sorry, I'm pretty new to programming, and it's basically the first project I had to actually design (I wish I did it before I started...) – xtl Nov 22 '19 at 10:26
  • @xtl: I think you misunderstood user104903. When you say "each product's default settings", that implies that each individual product has individual default settings. If that is the case, then these individual settings already are the "custom" settings as they are unique to the product. Hence the need for clarification. – Flater Nov 26 '19 at 11:35
0

I just went with SQLite solution. One table contains dynamic product list, second table contains settings linked to each product. Simple trigger does all the work to link these tables. It's simpler than XML on literally every front. I wish I decided to go this way right at the beginning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.