Skip to main content

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.

5
  • 3
    "good OO design can minimize branching through polymorphism" sort of: it moves branching from the actual business logic to the initialization/configuration code. The benefit usually is that "initialization and configuration" happens much less (as of occurences in the code, not in terms of "execution") than an explicit branching in the business logic would be needed. The downside is that there is no room for or depending on the target objects type within the business logic... Commented Mar 12, 2018 at 10:54
  • 3
    This may be of interest to you (basically, the author models a sum type as a hierarchy, with a bunch of overridden methods in the subclasses as a way to model pattern matching); also, in OO null checks can be avoided using the Null Object Pattern (just an object that does nothing for a given polymorphic operation). Commented Mar 12, 2018 at 11:03
  • The composite pattern might be worth a read. Commented Mar 12, 2018 at 11:13
  • 1
    Can you give an example of the kind of thing you want to improve? Commented Mar 12, 2018 at 15:58
  • @TimothyTruckle Good explanation, but it is not always "initialization/configuration". The branching occurs when you invoke the method, invisibly, but a dynamic language might allow you to add classes dynamically, in which case the branching is also changing dynamically. Commented Mar 15, 2018 at 1:41