| Conditions | 2 |
| Paths | 2 |
| Total Lines | 80 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 6 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | /** |
||
| 15 | constructor(options) { |
||
| 16 | |||
| 17 | /** |
||
| 18 | * The max number of bits used by data of this type. |
||
| 19 | * @type {number} |
||
| 20 | */ |
||
| 21 | this.bits = options["bits"]; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * If this type represent floating-point values or not. |
||
| 25 | * @type {boolean} |
||
| 26 | */ |
||
| 27 | this.char = options["char"]; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * If this type it is signed or not. |
||
| 31 | * @type {boolean} |
||
| 32 | */ |
||
| 33 | this.float = options["float"]; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * If this type is big-endian or not. |
||
| 37 | * @type {boolean} |
||
| 38 | */ |
||
| 39 | this.be = options["be"]; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * If this type it is signed or not. |
||
| 43 | * @type {boolean} |
||
| 44 | */ |
||
| 45 | this.signed = this.float ? true : options["signed"]; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * If this type represent a single value or |
||
| 49 | * an array. |
||
| 50 | * @type {boolean} |
||
| 51 | */ |
||
| 52 | this.single = true; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * The function to read values of this type |
||
| 56 | * from byte buffers. |
||
| 57 | * @type {Function} |
||
| 58 | */ |
||
| 59 | this.reader = null; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * The function to write values of this type |
||
| 63 | * to byte buffers. |
||
| 64 | * @type {Function} |
||
| 65 | */ |
||
| 66 | this.writer = null; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * The number of bytes used by data of this type. |
||
| 70 | * @type {number} |
||
| 71 | */ |
||
| 72 | this.offset = 0; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * The base used as a default representation for |
||
| 76 | * data of this type. |
||
| 77 | * @type {number} |
||
| 78 | */ |
||
| 79 | this.base = 10; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Min value for this type. |
||
| 83 | * @type {number} |
||
| 84 | */ |
||
| 85 | this.min = -Infinity; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Max value for this type. |
||
| 89 | * @type {number} |
||
| 90 | */ |
||
| 91 | this.max = Infinity; |
||
| 92 | |||
| 93 | this.build_(); |
||
| 94 | } |
||
| 95 | |||
| 179 |