Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
sourmìlk wrote:Out of curiosity, why C?
Ben-oni wrote:The best way to keep your OO skills sharp is to... learn functional programming.
Resilient wrote:It has been my experience that this is not how employers have seen it. For awhile I was very excited by Haskell and when I would talk about it at interviews I would get a raised eyebrow. But I do agree that it helped me thing about things.
Ben-oni wrote:Resilient wrote:
As for the particular question, hierarchical structure does not imply that the hierarchy should be hard coded into the system. This is one of the pitfalls of OO design. The "car" problem is actually one of the premier examples used for teaching OO design; strangely, it's one of the worst possible uses.
It is better to let the specifics of the hierarchy be stored in a data file that can be altered after compilation. ... 3) handle customer state interactions (say, saving and retrieving previous sessions, handling transactions, etc). Since (3) is where you want your main logic to be anyways, you can focus on that instead of getting lost in OO design decisions.
The MVC design should be fairly obvious, and implies only three classes. None of which represents a "4 door car". As design progresses, utility classes may be found to be useful, but they won't really be part of the main program architecture.
Resilient wrote:What kind of structure would you have for your data file in this case? You can't just go all willy-nilly and list wheelbase for some cars and not for others and expect the view to be able to display that in a consistent manner.
My first thought would be to have a couple of different views, one for cars, one for truck etc. but the problem obviously, is what do you do with the Subaru Baja? It's a car and a truck! Or what about when you want to add motorcycles as you pointed out?
From your description it sounds like for the Baja I might just list both car and truck data. But the view still needs to know how to display that. And that is where I don't quite follow your design. How do I go about rending things when the data file may be inconsistent? I can make a view for a car or a view for a truck. How can I design a view that is flexible to display a car/truck when I may not have been planning on it via using this data file? Does the data file need to contain data about how to render the data?
Users browsing this forum: Bing [Bot] and 14 guests