โ† All CAD Flashcard Decks

Code Refactoring and Quality Flashcards

7 cards from real CAD practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Code Refactoring and Quality flashcards as text
  1. Which refactoring technique replaces a subclass that differs from its sibling only in returned constant values with a field on the parent class?

    Answer: Replace Subclass with Fields

    Replace Subclass with Fields eliminates subclasses whose only variation is a constant value, moving that value as a field to the parent.

  2. What does 'coupling' measure in a software system, and what is the desired direction?

    Answer: The degree of interdependence between modules; low coupling is desired

    Coupling measures how much modules depend on each other; low coupling means changes in one module minimally impact others.

  3. In agile refactoring, what is 'opportunistic refactoring'?

    Answer: Refactoring code as you encounter it while working on a related feature or bug fix

    Opportunistic refactoring means improving code quality whenever you touch code for another reason, following the Boy Scout Rule.

  4. What problem does the 'Introduce Null Object' refactoring solve?

    Answer: Replaces null references with a special object that provides default behavior, eliminating repeated null checks

    A Null Object implements the expected interface with do-nothing behavior, removing the need for callers to check for null before each use.

  5. Which static analysis metric indicates potential violation of the Single Responsibility Principle when it is very high?

    Answer: Lack of Cohesion of Methods (LCOM)

    A high LCOM score means the methods in a class do not share common data, indicating the class likely has multiple unrelated responsibilities.

  6. When a method is too complex to be tested effectively and contains unrelated steps, which refactoring approach is most appropriate?

    Answer: Extract Method to break it into smaller, focused methods

    Extract Method decomposes a large, complex method into smaller named methods, each of which can be understood and tested independently.

  7. Which agile principle best justifies continuous refactoring as a core development practice?

    Answer: Technical excellence and good design enhance agility

    The Agile Manifesto's principle of continuous attention to technical excellence directly supports refactoring as essential to maintaining the ability to change quickly.