Timeline for Good design when polymorphism isn't possible
Current License: CC BY-SA 4.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 19, 2022 at 19:21 | history | edited | Christophe | CC BY-SA 4.0 |
added 4 characters in body; edited tags
|
Feb 9, 2021 at 3:00 | history | tweeted | twitter.com/StackSoftEng/status/1358974086966366216 | ||
Feb 4, 2021 at 18:17 | history | became hot network question | |||
Feb 4, 2021 at 12:40 | comment | added | Filip Milovanović | If you are already using a GUI framework of some sort (3rd party or homegrown), you likely already have some base class or an interface that can play the role of IComponent in Philip Kendall's answer (you don't necessarily have to introduce a new interface). Also, note that here, the usage pattern of one view for each component in the same entity is different from the typical ECS scenario where a system handles a bunch of components of the same type, so there is some justification to go outside of the usual ECS paradigm. | |
Feb 4, 2021 at 12:40 | comment | added | Filip Milovanović | You're right that the visitor makes more sense, but I'd like to point out something else: Components are the central abstraction in ECS (everything depends on a robust set of components). It's not your components that need to be polymorphic, it's the editor views (within the view rendering abstraction). With ECS, there should already be a mechanism that lets you recognize component types, so you can use that as an input to a view-producing factory (create a different view for each component type), data-bind each view to the corresponding component, and just plug it into the GUI framework. | |
Feb 4, 2021 at 11:03 | review | Close votes | |||
Feb 9, 2021 at 3:03 | |||||
Feb 4, 2021 at 11:03 | vote | accept | Alejandro | ||
Feb 4, 2021 at 10:50 | comment | added | amon | If you can't modify or wrap the components then there's no particularly good solutions. Instanceof it is. If you can modify them, then the visitor pattern would likely be a good solution. | |
Feb 4, 2021 at 10:39 | comment | added | gnat | Does this answer your question? How to tackle a 'branched' arrow head anti-pattern? | |
Feb 4, 2021 at 10:32 | answer | added | Philip Kendall | timeline score: 15 | |
Feb 4, 2021 at 10:14 | history | asked | Alejandro | CC BY-SA 4.0 |