Timeline for How can I add properties to subclasses and access them without casting from a superclass?
Current License: CC BY-SA 3.0
22 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 10, 2016 at 1:55 | vote | accept | TheIntern | ||
| Aug 10, 2015 at 13:00 | audit | Suggested edits | |||
| Aug 10, 2015 at 13:22 | |||||
| Jul 30, 2015 at 19:45 | comment | added | John Peters | Per the GoF "favor composition over inheritance" if there are properties unique to one class, those properties do not belong in a base class. When thinking of vertical inheritance chains be very strict about the "is-a" relationship, if a superclass is not really (and we mean really) a type of baseclass then it's a good candidate to contain something "hoizontally" rather than to inherit "vertically". I found this the hard way trying to inherit permissions on MVC site... Permissions are their own thing Views are NOT permissions. They contain them. | |
| Jul 28, 2015 at 23:29 | history | tweeted | twitter.com/#!/StackProgrammer/status/626172636016603138 | ||
| Jul 28, 2015 at 16:42 | comment | added | TheIntern | To give you some context, each product has 8 types of points that describe it. These points are time-based, and there's about 6 observations per point type. All these points are statistics about the product. Users need to view, graph, and edit the values of these points. So my Views are mostly graphs and datagrids. | |
| Jul 28, 2015 at 16:33 | comment | added | TheIntern | Yes, that's right. They're used in the viewmodel, which is where I'm trying to adapt them for display/interaction. They're from the model though. I'm building this whole project alone, so I'm trying to get it right in the model first. | |
| Jul 28, 2015 at 15:25 | comment | added | Ben Aaronson | So they're basically being used as view models? | |
| Jul 28, 2015 at 15:13 | comment | added | TheIntern | @Ben Aronson They're being graphed by a graphing control, displayed to the user in a DataGrid, etc. Some dimensions are changed by the user using the DataGrid. They're part of a business process. | |
| Jul 28, 2015 at 11:36 | comment | added | Ben Aaronson | Why do you need the properties? What are they being used for? | |
| Jul 28, 2015 at 6:45 | answer | added | Euphoric | timeline score: 0 | |
| Jul 28, 2015 at 6:33 | answer | added | Doc Brown | timeline score: 1 | |
| Jul 27, 2015 at 22:34 | history | edited | TheIntern | CC BY-SA 3.0 | added example of current class hierarchy |
| Jul 27, 2015 at 22:26 | history | edited | TheIntern | CC BY-SA 3.0 | added example of current class hierarchy |
| Jul 27, 2015 at 22:03 | history | edited | TheIntern | CC BY-SA 3.0 | added example of current class hierarchy |
| Jul 27, 2015 at 21:35 | comment | added | TheIntern | Putting the points into a List<PointBase> hides the Breakeven property of 8Point though. So, I can't show Breakeven in the DataGrid (or do other things with Breakeven, because I don't know that I'm dealing with an 8Point), but the user must see it. Furthermore, in the future, I expect there to be other custom properties for some points, but not others, so this problem will persist. This is where I'm stuck. I either need different lists for each subclass (bad), or to add Breakeven to PointBase (bad, b/c pts 1-7 don't have it). So I'm looking for a better way to model the points | |
| Jul 27, 2015 at 21:31 | comment | added | TheIntern | Three things change per subclass: (a) The way dimension A is computed (can be replaced with strategy) (b) The way dimension B is computed (can be replaced with strategy) (c) the properties that exist in some subclasses, but not others (I have no idea how to model this). This third part, (c), is the area where I'm having problems. 8Point has a Breakeven property, but the others don't. I often need to switch between which Point subclass I'm looking at (they're being displayed in a graph and DataGrid, switched around by user choice), so I have a List<PointBase>. | |
| Jul 27, 2015 at 20:22 | comment | added | Doc Brown | Can you provide some more details why you need 8 different point classes? What are the main differences between them? | |
| Jul 27, 2015 at 18:40 | answer | added | codebreaker | timeline score: 5 | |
| Jul 27, 2015 at 16:53 | history | edited | TheIntern | CC BY-SA 3.0 | added preference for interfaces |
| Jul 27, 2015 at 16:08 | history | edited | TheIntern | CC BY-SA 3.0 | added 170 characters in body |
| Jul 27, 2015 at 16:04 | review | First posts | |||
| Jul 27, 2015 at 19:33 | |||||
| Jul 27, 2015 at 16:02 | history | asked | TheIntern | CC BY-SA 3.0 |