reset password
Author Message
msargent
Posts: 519
Posted 18:04 Mar 07, 2013 |

Hi Dr. Sun,

Is there an advantage to keeping Lists in, say, our Project classes, since this info can be retrieved when we need it from the database?

cysun
Posts: 2935
Posted 20:04 Mar 07, 2013 |

I don't know what you meant by "keeping Lists in Project".

msargent
Posts: 519
Posted 20:31 Mar 07, 2013 |
cysun wrote:

I don't know what you meant by "keeping Lists in Project".


My Project class has a List of rewards. I was wondering if having this list is necessary if we can get the rewards for a given project with a query.
Last edited by msargent at 20:33 Mar 07, 2013.
cysun
Posts: 2935
Posted 20:46 Mar 07, 2013 |

I'd say it's still good to keep the List<Reward> in Project. In MVC, you need something to hold the data retrieved from the database, so you might as well use the List<Reward> to do that.

Generally speaking, the best class design is the one that models the real-world object the closest. For example, if you say "a project has a number of rewards", then you should have a List<Reward> in your Project class. With that said, without using an ORM library, the best class design is likely to make programming more difficult when you store data in a relational database. So for this assignment, as long as you don't break MVC (i.e. access database in controller then pass the data to view), you can choose whichever way you think is easier to program.