Naming, small functions, DRY, KISS, YAGNI, code smells, refactoring techniques, technical debt and code review practice.
40 cards · basic cards · AI-written, checked twice. Edit anything.
- What is the primary goal of the DRY principle?
Show answer
Eliminate code duplication by ensuring each piece of knowledge has a single, authoritative representation.
- What is a code smell?
Show answer
A surface-level characteristic indicating a potential deeper design problem that may require refactoring.
- State the principle: a class should have only one reason to change.
Show answer
Single Responsibility Principle (SRP)
- What does KISS stand for in programming?
Show answer
Keep It Simple, Stupid
- What does YAGNI mean?
Show answer
You Aren't Gonna Need It - avoid adding features before they are actually needed.
- Why should variable names be clear and descriptive?
Show answer
To make code self-documenting and reduce cognitive load for anyone reading or maintaining it.
- What is technical debt?
Show answer
The cost of rework created by shortcuts or poor design choices, paid later with interest accrued.
- What is the primary goal of code review?
Show answer
Catch bugs, share knowledge, ensure quality, and identify design issues before code reaches production.
- When should you extract a method from existing code?
Show answer
When code does more than one thing, becomes hard to understand, or logic could be reused elsewhere.
- What does cyclomatic complexity measure?
Show answer
The number of linearly independent paths through code, indicating complexity and testability difficulty.
- Define cohesion in code.
Show answer
The degree to which elements within a module are closely related and work together toward a single purpose.
- What is coupling in code architecture?
Show answer
The degree of interdependence between modules; high coupling makes code harder to modify and test.
- What is the Boy Scout Rule?
Show answer
Leave code cleaner than you found it, even if you only made a small improvement.
- Why should functions be kept small?
Show answer
Small functions are easier to understand, test, debug, and modify, and tend to have a single responsibility.
- What is a magic number in code?
Show answer
A hard-coded literal value with unclear meaning; should be replaced with a named constant.