Timeline for Abstract Property In Base Class To Force Programmer To Define It
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 9, 2015 at 13:32 | comment | added | GisMofx | @PeteKirkham each state requires a name, it should not be mutated after creation. The states' names are static/immutable. | |
| Jun 6, 2015 at 21:05 | comment | added | Pete Kirkham |
@GisMofx If you want to force the state name in each subclass, make the get abstract but don't require a state. Then each subclass will have to provide return "MyState1" as their implementation, and can add mutable storage for the value if they need it. But you need to clarify the requirements in the question - does every type of state require a StateName which can be read, and does any type of state require it to be mutated after creation?
|
|
| Jun 6, 2015 at 20:50 | comment | added | GisMofx |
I think you took that second statement out of context, but I will clarify. I don't need the Get/Set methods, I simply want StateName = "MyState1" in each State. If I do not have that statement in the state class, then ideally Visual Studio will generate an error.
|
|
| Jun 6, 2015 at 17:56 | history | answered | null | CC BY-SA 3.0 |