Skip to main content

Timeline for Switch vs Polymorphism

Current License: CC BY-SA 3.0

15 events
when toggle format what by license comment
Jul 8, 2017 at 9:31 review Close votes
Jul 13, 2017 at 3:01
Apr 20, 2017 at 10:39 comment added Giorgio This is the well-known expression problem. If you expect your application to get new data-types in the future while the set of operations on those types remains constant, then use polymorphism. If you expect your collection of data types to remain constant, use switch. If you expect you are going to add new data types and operations, use the visitor pattern.
Apr 20, 2017 at 8:20 comment added unflores Though not responding to your original question, I notice that you have the notion of cubes, which while it accurately depicts the board game version of pandemic ;), it may not reflect the visuals that your version provides and thus not be the best name. Infections might be a better name, but it's best to avoid naming based off of implementation/design details if you can.
Apr 20, 2017 at 7:50 answer added Roland Tepp timeline score: 2
Apr 20, 2017 at 3:50 history tweeted twitter.com/StackSoftEng/status/854905171419246593
Apr 16, 2017 at 8:32 answer added gnasher729 timeline score: 3
Apr 15, 2017 at 18:15 answer added civan timeline score: 5
Apr 15, 2017 at 16:51 answer added Ewan timeline score: 19
Apr 15, 2017 at 16:24 review Close votes
Apr 20, 2017 at 3:01
Apr 15, 2017 at 16:21 answer added Alex timeline score: 1
Apr 15, 2017 at 16:20 comment added senevoldsen Even though the four diseases is a fixed requirement, you might consider neither of the two options and going for a Map or array "indexed by the color" instead, with count as the value. If there were 400 fixed diseases, would you have 400 private members? A Map makes it easy to query, and you have direct access to total number of cubes using `size()'.
Apr 15, 2017 at 16:11 history edited amon CC BY-SA 3.0
added syntax highlighting, condensed code formatting
Apr 15, 2017 at 16:09 comment added gnat Possible duplicate of Refactoring Switch Statements and is there any real use for Switch Statements at all?
Apr 15, 2017 at 16:00 review First posts
May 15, 2017 at 15:58
Apr 15, 2017 at 15:56 history asked Tirke CC BY-SA 3.0