Sha256: b0af66bb21a2568a83b6f0491fc7d2864bc90c42f90f3a20d7f7c55f41b164e5

Contents?: true

Size: 935 Bytes

Versions: 15

Compression:

Stored size: 935 Bytes

Contents

# Simulated Polymorphism

## Introduction

Simulated Polymorphism occurs when

* code uses a case statement (especially on a type field);
* or code has several if statements in a row (especially if they're comparing against the same value);
* or code uses instance_of?, kind_of?, is_a?, or === to decide what type it's working with;
* or multiple conditionals in different places test the same value.

Conditional code is hard to read and understand, because the reader must hold more state in his head. When the same value is tested in multiple places throughout an application, any change to the set of possible values will require many methods and classes to change. Tests for the type of an object may indicate that the abstraction represented by that type is not completely defined (or understood).

## Current Support in reek

`reek` checks for [Repeated Conditional](Repeated-Conditional.md)  and for [Nil Check](Nil-Check.md).

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
reek-3.5.0 docs/Simulated-Polymorphism.md
reek-3.4.1 docs/Simulated-Polymorphism.md
reek-3.4.0 docs/Simulated-Polymorphism.md
reek-3.3.1 docs/Simulated-Polymorphism.md
reek-3.3.0 docs/Simulated-Polymorphism.md
reek-3.2.1 docs/Simulated-Polymorphism.md
reek-3.2 docs/Simulated-Polymorphism.md
reek-3.1 docs/Simulated-Polymorphism.md
reek-3.0.4 docs/Simulated-Polymorphism.md
reek-3.0.3 docs/Simulated-Polymorphism.md
reek-3.0.2 docs/Simulated-Polymorphism.md
reek-3.0.1 docs/Simulated-Polymorphism.md
reek-3.0.0 docs/Simulated-Polymorphism.md
reek-2.2.1 docs/Simulated-Polymorphism.md
reek-2.2.0 docs/Simulated-Polymorphism.md