You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
-
3I'd call this approach "Horrible", frankly. Strings are a terrible key for data, they're easily typoable and any issues with them are only thrown up at runtime. If for some reason you cannot use properties, I see no downside to having a dictionary of SomeEnum -> Object, which still sucks due to losing type safety on one end, but gains a very little back on the other.Phoshi– Phoshi2013-11-07 14:19:05 +00:00Commented Nov 7, 2013 at 14:19
-
@Phoshi yes, this is essentially taking a dynamic language approach and applying it to a statically typed language, so you sacrifice static typing for extensibility.Mark Heath– Mark Heath2013-11-07 15:01:25 +00:00Commented Nov 7, 2013 at 15:01
-
1Except that there are better ways to achieve this sort of flexibility that don't end up killing type safety quite so bad, and I'm not sure what benefit you're getting here other than it being quicker to develop that component. Now, if there aren't many other components, that's totally valid, but losing type safety in your data storage engine is insane in a larger project. At best, you're going to litter your code with instanceof and (Casting).Phoshi– Phoshi2013-11-07 15:50:58 +00:00Commented Nov 7, 2013 at 15:50
-
No, it's instanceof that this approach eliminates since there are no derived types any more. I didn't want to bloat the question with long details about why I'm interested in this approach, but a big part of the driver is getting rid of instanceof, and dealing with the challenges of needing to deserialize objects from any previous (or future) version of the application.Mark Heath– Mark Heath2013-11-07 15:58:50 +00:00Commented Nov 7, 2013 at 15:58
-
If you're never doing runtime typechecks then you can only sanely treat everything as "object". I mean, I guess you can treat everything as strings if you ToString everything before use, but this is still all of the disadvantages of loosely typed programming without the metadata that actually makes that work. Treating everything as Object and never changing types isn't making the type system more flexible, it's making the type system work against you for no benefit.Phoshi– Phoshi2013-11-08 09:24:24 +00:00Commented Nov 8, 2013 at 9:24
Add a comment
|
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-cs