Conditions | 1 |
Paths | 1 |
Total Lines | 219 |
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 | <?php |
||
255 | public function testBuild() { |
||
256 | /* Test uses the alternate format for subgraphs: |
||
257 | subgraph type { |
||
258 | graph [ rank=same ]; |
||
259 | <nodes> |
||
260 | } |
||
261 | instead of: |
||
262 | subgraph type { |
||
263 | rank = same; |
||
264 | <nodes> |
||
265 | } |
||
266 | */ |
||
267 | $expected = <<<EOT |
||
268 | digraph asde91 { |
||
269 | ranksep=0.75; |
||
270 | |||
271 | subgraph type { |
||
272 | rank=same; |
||
273 | |||
274 | "Software IS"; |
||
275 | "Configuration Mgt"; |
||
276 | "Architecture & Libraries"; |
||
277 | Process; |
||
278 | } /* /subgraph type */ |
||
279 | subgraph past { |
||
280 | rank=same; |
||
281 | |||
282 | "Bourne sh"; |
||
283 | make; |
||
284 | SCCS; |
||
285 | yacc; |
||
286 | cron; |
||
287 | } /* /subgraph past */ |
||
288 | subgraph 1978 { |
||
289 | rank=same; |
||
290 | |||
291 | "Reiser cpp"; |
||
292 | Cshell; |
||
293 | } /* /subgraph 1978 */ |
||
294 | subgraph 1980 { |
||
295 | rank=same; |
||
296 | |||
297 | emacs; |
||
298 | build; |
||
299 | vi; |
||
300 | } /* /subgraph 1980 */ |
||
301 | subgraph 1982 { |
||
302 | rank=same; |
||
303 | |||
304 | "<curses>"; |
||
305 | RCS; |
||
306 | IMX; |
||
307 | SYNED; |
||
308 | } /* /subgraph 1982 */ |
||
309 | subgraph 1983 { |
||
310 | rank=same; |
||
311 | |||
312 | ksh; |
||
313 | IFS; |
||
314 | TTU; |
||
315 | } /* /subgraph 1983 */ |
||
316 | subgraph 1985 { |
||
317 | rank=same; |
||
318 | |||
319 | nmake; |
||
320 | Peggy; |
||
321 | } /* /subgraph 1985 */ |
||
322 | subgraph 1986 { |
||
323 | rank=same; |
||
324 | |||
325 | ncpp; |
||
326 | "ksh-i"; |
||
327 | "<curses-i>"; |
||
328 | PG2; |
||
329 | "C*"; |
||
330 | } /* /subgraph 1986 */ |
||
331 | subgraph 1987 { |
||
332 | rank=same; |
||
333 | |||
334 | "Ansi cpp"; |
||
335 | "nmake 2.0"; |
||
336 | "3D File System"; |
||
337 | fdelta; |
||
338 | DAG; |
||
339 | CSAS; |
||
340 | } /* /subgraph 1987 */ |
||
341 | subgraph 1988 { |
||
342 | rank=same; |
||
343 | |||
344 | CIA; |
||
345 | SBCS; |
||
346 | "ksh-88"; |
||
347 | "PEGASUS/PML"; |
||
348 | PAX; |
||
349 | backtalk; |
||
350 | } /* /subgraph 1988 */ |
||
351 | subgraph 1989 { |
||
352 | rank=same; |
||
353 | |||
354 | "CIA++"; |
||
355 | APP; |
||
356 | SHIP; |
||
357 | DataShare; |
||
358 | ryacc; |
||
359 | Mosaic; |
||
360 | } /* /subgraph 1989 */ |
||
361 | subgraph 1990 { |
||
362 | rank=same; |
||
363 | |||
364 | libft; |
||
365 | CoShell; |
||
366 | DIA; |
||
367 | "IFS-i"; |
||
368 | kyacc; |
||
369 | sfio; |
||
370 | yeast; |
||
371 | "ML-X"; |
||
372 | DOT; |
||
373 | } /* /subgraph 1990 */ |
||
374 | subgraph future { |
||
375 | rank=same; |
||
376 | |||
377 | "Adv. Software Technology"; |
||
378 | } /* /subgraph future */ |
||
379 | past -> 1978; |
||
380 | 1978 -> 1980; |
||
381 | 1980 -> 1982; |
||
382 | 1982 -> 1983; |
||
383 | 1983 -> 1985; |
||
384 | 1985 -> 1986; |
||
385 | 1986 -> 1987; |
||
386 | 1987 -> 1988; |
||
387 | 1988 -> 1989; |
||
388 | 1989 -> 1990; |
||
389 | 1990 -> future; |
||
390 | SCCS -> RCS; |
||
391 | SCCS -> "3D File System"; |
||
392 | SCCS -> nmake; |
||
393 | make -> nmake; |
||
394 | make -> build; |
||
395 | "Bourne sh" -> Cshell; |
||
396 | "Bourne sh" -> ksh; |
||
397 | yacc -> ryacc; |
||
398 | cron -> yeast; |
||
399 | "Reiser cpp" -> ncpp; |
||
400 | Cshell -> ksh; |
||
401 | build -> "nmake 2.0"; |
||
402 | vi -> ksh; |
||
403 | vi -> "<curses>"; |
||
404 | emacs -> ksh; |
||
405 | RCS -> SBCS; |
||
406 | RCS -> fdelta; |
||
407 | "<curses>" -> "<curses-i>"; |
||
408 | SYNED -> Peggy; |
||
409 | IMX -> TTU; |
||
410 | ksh -> nmake; |
||
411 | ksh -> "ksh-i"; |
||
412 | ksh -> "ksh-88"; |
||
413 | IFS -> "<curses-i>"; |
||
414 | IFS -> sfio; |
||
415 | IFS -> "IFS-i"; |
||
416 | TTU -> PG2; |
||
417 | nmake -> ksh; |
||
418 | nmake -> ncpp; |
||
419 | nmake -> "3D File System"; |
||
420 | nmake -> "nmake 2.0"; |
||
421 | Peggy -> "PEGASUS/PML"; |
||
422 | Peggy -> ryacc; |
||
423 | "C*" -> CSAS; |
||
424 | ncpp -> "Ansi cpp"; |
||
425 | "<curses-i>" -> fdelta; |
||
426 | "ksh-i" -> "ksh-88"; |
||
427 | PG2 -> backtalk; |
||
428 | DAG -> "Software IS"; |
||
429 | DAG -> DOT; |
||
430 | DAG -> DIA; |
||
431 | CSAS -> CIA; |
||
432 | "Ansi cpp" -> "Configuration Mgt"; |
||
433 | fdelta -> SBCS; |
||
434 | fdelta -> PAX; |
||
435 | "3D File System" -> "Configuration Mgt"; |
||
436 | "nmake 2.0" -> "Configuration Mgt"; |
||
437 | "nmake 2.0" -> CoShell; |
||
438 | CIA -> "CIA++"; |
||
439 | CIA -> DIA; |
||
440 | SBCS -> "Configuration Mgt"; |
||
441 | PAX -> SHIP; |
||
442 | "ksh-88" -> "Configuration Mgt"; |
||
443 | "ksh-88" -> "Architecture & Libraries"; |
||
444 | "ksh-88" -> sfio; |
||
445 | "PEGASUS/PML" -> "ML-X"; |
||
446 | "PEGASUS/PML" -> "Architecture & Libraries"; |
||
447 | backtalk -> DataShare; |
||
448 | "CIA++" -> "Software IS"; |
||
449 | APP -> DIA; |
||
450 | APP -> "Software IS"; |
||
451 | SHIP -> "Configuration Mgt"; |
||
452 | DataShare -> "Architecture & Libraries"; |
||
453 | ryacc -> kyacc; |
||
454 | Mosaic -> Process; |
||
455 | DOT -> "Software IS"; |
||
456 | DIA -> "Software IS"; |
||
457 | libft -> "Software IS"; |
||
458 | CoShell -> "Configuration Mgt"; |
||
459 | CoShell -> "Architecture & Libraries"; |
||
460 | sfio -> "Architecture & Libraries"; |
||
461 | "IFS-i" -> "Architecture & Libraries"; |
||
462 | "ML-X" -> "Architecture & Libraries"; |
||
463 | kyacc -> "Architecture & Libraries"; |
||
464 | yeast -> Process; |
||
465 | "Architecture & Libraries" -> "Adv. Software Technology"; |
||
466 | "Software IS" -> "Adv. Software Technology"; |
||
467 | "Configuration Mgt" -> "Adv. Software Technology"; |
||
468 | Process -> "Adv. Software Technology"; |
||
469 | } /* /digraph asde91 */ |
||
470 | |||
471 | EOT; |
||
472 | $this->check($expected, "Image_GraphViz test 9 passed."); |
||
473 | } |
||
474 | } |
||
475 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.