Note that there are some explanatory texts on larger screens.

plurals
  1. PODesign Question - OO food application
    text
    copied!<p>Say I have a number of usercontrols, each usercontrol inside a tabitem, inside a window.</p> <p>For example, let say this is a food collection application. Then we have tabs Fruit, Vegetables and Snacks. Each tab will show a list of food of that subject, and allow the user to add, delete, modify the food in each section. The food is stored in seperate textfiles, i.e. Fruit.txt, Vegetable.txt, Snack.txt</p> <p>The actual text files might look something like this (vegetable.txt):</p> <pre><code>Name Carbs Fat Eggplant 2 1.1 Cucumber 3 0.5 etc </code></pre> <p>Now this is a large list and there is a load method which pulls all the vegetables out into a List</p> <p>The question I have is this loadVegetables method is in the code behind file, and I end up repeating this load method all over the place, because I have another of other screens like ReviewAllFood, AddVegetable, etc. along with all the other load methods for fruit and snacks.</p> <p>This is more of a design question, I'm wondering how I set this up to not repeat this code. I could have a VegetableManager (or something) class where the load method is, but does this actually mean less repeated code? Then in each screen I have to create object of VegetableManager and call its load method anyway. So I guess efficiency wise its no better, but I do achieve a better design.</p> <p>I think I'm missing something here. It's been a while since I studied cohesion and coupling and I think i'm confusing myself with these concepts at the moment. Appreciate if someone could suggest a design for this situation and explain why they chose it and why its better than how i'm doing it at the moment.</p> <p>Thanks for reading.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload