Conditions | 2 |
Paths | 2 |
Total Lines | 63 |
Lines | 0 |
Ratio | 0 % |
Changes | 9 | ||
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 | * The max number of bits used by data of this type. |
||
18 | * @type {number} |
||
19 | */ |
||
20 | this.bits = options["bits"]; |
||
21 | /** |
||
22 | * If this type represent floating-point values or not. |
||
23 | * @type {boolean} |
||
24 | */ |
||
25 | this.char = options["char"]; |
||
26 | /** |
||
27 | * If this type it is signed or not. |
||
28 | * @type {boolean} |
||
29 | */ |
||
30 | this.float = options["float"]; |
||
31 | /** |
||
32 | * If this type is big-endian or not. |
||
33 | * @type {boolean} |
||
34 | */ |
||
35 | this.be = options["be"]; |
||
36 | /** |
||
37 | * If this type it is signed or not. |
||
38 | * @type {boolean} |
||
39 | */ |
||
40 | this.signed = this.float ? true : options["signed"]; |
||
41 | /** |
||
42 | * If this type represent a single value or an array. |
||
43 | * @type {boolean} |
||
44 | */ |
||
45 | this.single = true; |
||
46 | /** |
||
47 | * The function to read values of this type from buffers. |
||
48 | * @type {Function} |
||
49 | */ |
||
50 | this.reader = null; |
||
51 | /** |
||
52 | * The function to write values of this type to buffers. |
||
53 | * @type {Function} |
||
54 | */ |
||
55 | this.writer = null; |
||
56 | /** |
||
57 | * The number of bytes used by data of this type. |
||
58 | * @type {number} |
||
59 | */ |
||
60 | this.offset = 0; |
||
61 | /** |
||
62 | * The base used to represent data of this type. |
||
63 | * @type {number} |
||
64 | */ |
||
65 | this.base = 10; |
||
66 | /** |
||
67 | * Min value for numbers of this type. |
||
68 | * @type {number} |
||
69 | */ |
||
70 | this.min = -Infinity; |
||
71 | /** |
||
72 | * Max value for numbers of this type. |
||
73 | * @type {number} |
||
74 | */ |
||
75 | this.max = Infinity; |
||
76 | this.build_(); |
||
77 | } |
||
78 | |||
158 |