Conditions | 1 |
Total Lines | 65 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 | import json |
||
217 | @staticmethod |
||
218 | def big_oval_tree(): |
||
219 | return OvalNode( |
||
220 | node_id=1, |
||
221 | node_type='operator', |
||
222 | value='and', |
||
223 | children=[ |
||
224 | OvalNode( |
||
225 | node_id=2, |
||
226 | node_type='value', |
||
227 | value="false", |
||
228 | ), |
||
229 | OvalNode( |
||
230 | node_id=3, |
||
231 | node_type='operator', |
||
232 | value="xor", |
||
233 | children=[ |
||
234 | OvalNode( |
||
235 | node_id=4, |
||
236 | node_type='value', |
||
237 | value='true', |
||
238 | ), |
||
239 | OvalNode( |
||
240 | node_id=5, |
||
241 | node_type='operator', |
||
242 | value='one', |
||
243 | children=[ |
||
244 | OvalNode( |
||
245 | node_id=6, |
||
246 | node_type='value', |
||
247 | value='noteval', |
||
248 | ), |
||
249 | OvalNode( |
||
250 | node_id=7, |
||
251 | node_type='value', |
||
252 | value='true', |
||
253 | ), |
||
254 | OvalNode( |
||
255 | node_id=8, |
||
256 | node_type='value', |
||
257 | value='notappl', |
||
258 | ), |
||
259 | ] |
||
260 | ), |
||
261 | OvalNode( |
||
262 | node_id=9, |
||
263 | node_type='value', |
||
264 | value='error', |
||
265 | ), |
||
266 | ] |
||
267 | ), |
||
268 | OvalNode( |
||
269 | node_id=10, |
||
270 | node_type='operator', |
||
271 | value='or', |
||
272 | children=[ |
||
273 | OvalNode( |
||
274 | node_id=11, |
||
275 | node_type='value', |
||
276 | value="unknown", |
||
277 | ), |
||
278 | OvalNode( |
||
279 | node_id=12, |
||
280 | node_type='value', |
||
281 | value="true", |
||
282 | ), |
||
385 |