FlashKeepers

Programming Concepts · College · College and University

Clean Code and Refactoring

Naming, small functions, DRY, KISS, YAGNI, code smells, refactoring techniques, technical debt and code review practice.

About this set

40 basic cards for College Programming Concepts. It opens with "What is the primary goal of the DRY principle?" and "What is a code smell?". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is the primary goal of the DRY principle?
Show answerEliminate code duplication by ensuring each piece of knowledge has a single, authoritative representation.
What is a code smell?
Show answerA 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 answerSingle Responsibility Principle (SRP)
What does KISS stand for in programming?
Show answerKeep It Simple, Stupid
What does YAGNI mean?
Show answerYou Aren't Gonna Need It - avoid adding features before they are actually needed.
Why should variable names be clear and descriptive?
Show answerTo make code self-documenting and reduce cognitive load for anyone reading or maintaining it.
What is technical debt?
Show answerThe cost of rework created by shortcuts or poor design choices, paid later with interest accrued.
What is the primary goal of code review?
Show answerCatch bugs, share knowledge, ensure quality, and identify design issues before code reaches production.
When should you extract a method from existing code?
Show answerWhen code does more than one thing, becomes hard to understand, or logic could be reused elsewhere.
What does cyclomatic complexity measure?
Show answerThe number of linearly independent paths through code, indicating complexity and testability difficulty.
Define cohesion in code.
Show answerThe degree to which elements within a module are closely related and work together toward a single purpose.
What is coupling in code architecture?
Show answerThe degree of interdependence between modules; high coupling makes code harder to modify and test.
What is the Boy Scout Rule?
Show answerLeave code cleaner than you found it, even if you only made a small improvement.
Why should functions be kept small?
Show answerSmall functions are easier to understand, test, debug, and modify, and tend to have a single responsibility.
What is a magic number in code?
Show answerA hard-coded literal value with unclear meaning; should be replaced with a named constant.

25 more cards in the app

Study this set free