CODE SMELLS

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/8

flashcard set

Earn XP

Description and Tags

The code smells to look out for in COMP2511

9 Terms

1
New cards

What are the features of a “Refused Bequest” code smell?

  • When a class inherits behaviour it doesn’t need so it either doesn’t do anything or throws an error.

  • This can muddy a classes functionality or perceived behaviour.

  • SOLUTION: Decay useless behaviour into an interface and implement the interface into the relevant classes.


2
New cards

What are the features of a “Long Parameter List” code smell?

  • When a classes method/constructor has a very long parameter list.

  • Makes a class less legible, increases coupling

  • SOLUTION: Decay parameter list into a data class and pass the class instead.


3
New cards

What are the features of a “Large Method/Class” code smell?

  • When a class is particularly large (over 200 lines) or has a method that is particularly large (over 50-60 lines).

  • SOLUTION: Decay behaviour into subclasses/new methods.


4
New cards

What are the features of a “Similar Code Fragments” code smell?

  • When a classes have code snippets that are very similar or identical to each other.

  • SOLUTION: Decay the shared behaviour into the superclass or a shared interface.


5
New cards

What are the features of a “Feature Envy” code smell?

  • When a class cares more about the functionality/data of another class.

  • SOLUTION: Move the offending methods to the class that the method actually gives a gaf about.


6
New cards

What are the features of a “Divergent Change” code smell?

  • When making changes to a single class, you must make modifications in multiple places within the class.

  • SOLUTION: Separate the reasons for change into separate classes.


7
New cards

What are the features of a “Shotgun Surgery” code smell?

  • When making changes to a single class, you must make modifications in multiple places in other classes.

  • SOLUTION: Consolidate related changes into a single class/move offending methods to relevant classes.


8
New cards

What are the features of a “Lazy Class” code smell?

  • A class that is very small and doesn’t do a lot.

  • SOLUTION: Decay functionality into exisiting classes.


9
New cards

What are the features of a “Data Class” code smell?

  • A class that only holds data and doesn’t actually complete any functionality other than getting/setting.

  • SOLUTION: Check if there is functionality that is better held by the data class rather than another class, otherwise decay data class into a super class?