SOLID or Smelly?
What Test Is This?
Choose the Right Double
Refactor Rescue
Testing & Architecture Hot Takes
100

A UserManager directly:

  • prints invoices,
  • sends emails,
  • validates passwords,
  • and writes SQL queries.

What is the BIGGEST design issue?

SRP — too many unrelated responsibilities.

100

A pure validation method is tested with no database, no files, and no external systems.

What type of test is this?

Unit test.

100

You only need a dependency to return one fixed value during a test.

Which test double is MOST appropriate?

Stub

100

Question

A UI button handler contains:

  • validation,
  • business rules,
  • SQL queries,
  • and formatting logic.

What is the BEST first refactor direction?

Separate responsibilities into layers/classes.

100

True or False:
Dependency Injection and Dependency Inversion Principle are the same concept.

False.

200

A subclass of Bird throws:


UnsupportedOperationException


when:

fly()

is called.

What principle is MOST clearly being violated?

LSP

200

A manager class is tested using a fake repository backed by an ArrayList.

What type of test is this MOST likely?


Integration test across a seam.

200

You want to verify that:


sendEmail()


was called exactly once.

Which test double is MOST appropriate?


Mock.

200

Three classes duplicate the same password validation logic.

What design problem exists?


DRY violation / duplicated logic.

200

True or False:
A test using a fake repository can still be considered integration testing.


True

300

A team adds:

  • factories,
  • adapters,
  • repositories,
  • and dependency injection

to a 300-line student project with two screens and no persistence.

What design issue is MOST likely occurring?

Overengineering / violating KISS or YAGNI.

300

A test launches the full application, clicks buttons, and saves data into SQLite.

What type of test is this?


End-to-end test.

300

You want realistic persistence behaviour without using a real SQL database.

Which test double is MOST appropriate?


False

300

A class creates all dependencies internally using:

new

What design improvement would MOST improve testability?

Dependency injection.

300

What is the MAIN advantage of depending on interfaces instead of concrete classes?

Reduced coupling / easier substitution/testing.

400

A checkout system supports new payment methods by adding new strategy classes without modifying checkout logic.

What principle is MOST clearly being followed?

OCP

400

A test checks communication between:

  • logic layer
  • persistence layer

but does not involve the UI.

What type of test is this?

Integration test.

400

You are testing a pure calculator class with no external dependencies.

Which test double is MOST appropriate?

Real object (no double needed).

400

A system already uses constructor injection but still depends directly on concrete classes.

What important design principle is still weak?

DIP

400

Why can excessive mocking become dangerous?


Tests become brittle and overly coupled to implementation details.

500

A team creates:

  • UserManager,
  • UserService,
  • UserCoordinator,
  • UserHandler,
  • UserProcessor,
  • and UserController

but responsibilities overlap heavily and developers are unsure where new logic should go.

What is the MOST significant design problem?

Low cohesion / poor separation of concerns.

500

A test mocks every dependency, including:

  • DTOs,
  • entities,
  • and simple value objects.

What major testing problem is MOST likely occurring?


Over-mocking / brittle test design.

500

You want mostly real behaviour, but need to override one method during testing.

Which test double is MOST appropriate?


Spy

500

A student proposes:

  • factories,
  • builders,
  • adapters,
  • repositories,
  • and 12 interfaces

for a tiny application with two screens.

What design problem is MOST likely occurring?

Overengineering / violating KISS or YAGNI.

500

A design contains many interfaces and abstractions but is difficult to understand or modify.

What important lesson does this illustrate?

More abstraction does not automatically mean better design.

IT DEPENDS (on where/why we use them)