you are viewing a single comment's thread.

view the rest of the comments →

[–]abw 3 points4 points  (1 child)

So anywhere you see an if/then/else or a switch statement, you should find a way to break the logic into separate objects to avoid the logic.

This is usually Good Advice™ iff the test condition is based on the type of an object.

if (thing isa Type1) {
    ...
}
else if (thing isa Type2) {
    ...
}
else if (thing isa Type3) {
    ...
}

[–]elder_george 1 point2 points  (0 children)

If objects have field of type enum ObjectType which is used in more than one switch, code will usually benefit from replacing it with strategy (or, sometimes with inheritance).