Timeline for Building car factory with custom features per car
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 30, 2016 at 21:05 | comment | added | Ziv Weissman | When I'm trying to recall the interview I remember they always asked: A. how do I compare it to another feature and B: how do I add a new feature? and everything I said they disapproved saying it is "not flexible enough". It is really "eating my head", really wonder if there is another magical approach they wanted to hear. | |
Aug 30, 2016 at 14:58 | comment | added | JanDotNet | Yes, if you have frequently new kinds of features it is pobably not the way to go. Again, I would not suggest a factory for that problem - it is just one way to solve it (The way that was ask for in the interview). | |
Aug 30, 2016 at 14:38 | comment | added | Ziv Weissman | But then when I add a new feature I must add it to each of the implementations... seems like a headache, unless I use reflection on the base car type to get all of the classes that inherit "Feature" - using reflection on design pattern considered a bad practice? | |
Aug 30, 2016 at 14:09 | comment | added | JanDotNet |
You could provide a method Car.GetRating that must be implemented for each concrete Car class, or you could also return a list of all features and sum up the ratings as you did...
|
|
Aug 30, 2016 at 13:33 | comment | added | Ziv Weissman | @JanDotNet I wonder though if I use Abstract car class with CruiseControl and another Abstract car class without it, how do I compare it? Generally how would you build a compare between two cars with different CruiseControll? | |
Aug 30, 2016 at 8:30 | comment | added | t3chb0t | I'd go with a buillder anyway. Factories are very limited and not easily extendable. I always try to avoid them. | |
Aug 30, 2016 at 8:18 | comment | added | Ziv Weissman | You are probably right I should have gone with the "basics" and not over thinking XD | |
Aug 30, 2016 at 8:13 | comment | added | JanDotNet | Actually I really like the feature list approach because of the high degree of flexibility. However, you sayed "I was once asked in an interview to build a factory that makes cars" so probably they don't want to get a good design for their dummy problem, probably they want just see if you know what a factory is ;). | |
Aug 30, 2016 at 8:05 | comment | added | Ziv Weissman | Thank you for your input! I thought about adding each property like CruiseControl ect to each car, but it seems "more complicated" when I want to add a new feature to some cars. As for the list, yes it is a major downside that I can add two types of the same feature but if I control the adding to the list and no public constractor, is it not enough "design-wise"? | |
Aug 30, 2016 at 8:04 | history | edited | JanDotNet | CC BY-SA 3.0 |
typo
|
Aug 30, 2016 at 7:56 | history | answered | JanDotNet | CC BY-SA 3.0 |