Where would a list fit into oop?
Posted: Sun Aug 12, 2012 3:23 am
I'm finally making some progress in object oriented programming and I'm really starting to enjoy the theory now that my brain isn't fighting it so much 
One issue I can't seem to get past is where does the list fit in? I'm sure I'm missing something obvious, but I've been stuck on this for a while. Let's say I have a User class and a Car class. Where would I get a list of cars? Of course I could get the list from either class, but neither "feels" right. Creating a CarList class also feels a little weird. I've also considered just running a query to get the list, iterating over the result, and building a Car object for each record. But the idea of running a query so directly while I'm working so hard to abstract everything seems really backwards.
I know this is a random question, and thanks in advance for taking the time to consider it. I feel like all of the sudden I'm righting really handsome code and I don't want to head down the wrong path with such a fundamental issue.
Any advice or guidance is greatly appreciated! Thanks!!
One issue I can't seem to get past is where does the list fit in? I'm sure I'm missing something obvious, but I've been stuck on this for a while. Let's say I have a User class and a Car class. Where would I get a list of cars? Of course I could get the list from either class, but neither "feels" right. Creating a CarList class also feels a little weird. I've also considered just running a query to get the list, iterating over the result, and building a Car object for each record. But the idea of running a query so directly while I'm working so hard to abstract everything seems really backwards.
I know this is a random question, and thanks in advance for taking the time to consider it. I feel like all of the sudden I'm righting really handsome code and I don't want to head down the wrong path with such a fundamental issue.
Any advice or guidance is greatly appreciated! Thanks!!