Exam 2 - L13 - SOLID Principles Flashcards

1
Q

Who introduced the SOLID principles and when?

A

Robert C Martin in the early 2000s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does the Single Responsibility Principle (SRP) state?

A

A class should have only one reason to change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does Axis of Change help achieve SRP? (Single Responsibility Principal)

A

Axis of Change - A key area or dimension around which changes to a system are likely to occur.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does logical separation of namespaces help achieve SRP? (Single Responsibility Principal)

A

Putting classes into different namespaces based on their distinct responsibilities , you enforce that each area of your code only focuses on one thing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does Separation of Concerns help achieve SRP? (Single Responsibility Principal?

A

Divides a system into distinct sections, each responsible for a specific aspect of functionality, which minimizes overlap. Ensures that each class only has one reason to change.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does Frequent Refactoring help achieve SRP? (Single Responsibility Principal)

A

By continuously revisiting and improving your code, you catch responsibility creep early and reorganize classes before they grow bloated.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Agile Development and why is it related to SOLID?

A

Software development process that prioritizes flexibility, small and frequent releases, collaboration, responding to change.

SOLID is a set of coding principles for designing software that is easy to modify, extend, refactor, and test. Agile’s goals are fast change, continuous delivery, and adapting quickly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is YAGNI and how is it related to SOLID principals?

A

“You Aren’t Gonna Need It” - Don’t add functionality until you actually need it.

SOLID helps design clean, flexible code when real complexity arises. TOGETHER YAGNI avoid premature abstraction; SOLID structures real, necessary abstractions correctly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is KISS and how is it related to SOLID principals?

A

(Keep It Simple, Stupid) - Prefer the simplest possible solution that solves the problem - no extra complexity, no cleverness for its own sake.

KISS keeps solutions simple. SOLID organizes code cleanly when real complexity appears. Together: start simple (KISS), apply SOLID when needed to maintain clarity and flexibility

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Vertical Slice and how is it related to SOLID?

A

A way of organizing code by feature, not by layer. Each slice includes the UI, logic, and data access needed to implement one feature - grouped together.

Aligns with SOLID by enforcing SRP (Single responsibility) reducing coupling, and making the system easier to extend without breaking existing code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Big Ball of Mud and how is it related to SOLID?

A

A disorganized, messy system with no clear structure, separation of concerns, or boundaries.

Results from ignoring SOLID principals, leading to tightly coupled, hard-to-maintain software.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How does TDD (Test-Driven Development) support SRP?

A

Encourages small, focused units of behavior, which naturally leads to classes and functions having a single responsibility.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the Open / Closed Principle (OCP) state?

A

Software should be open for extension but closed for modification

  • meaning you can add new behavior without changing existing code.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can you follow Open / Closed Principal (OCP) when adding new features?

A

Create new classes using interfaces or abstract classes rather than modifying existing code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How does Test-Driven Development (TDD) support OCP

A

TDD forces you to write code that can pass new tests without rewriting old code. This encourages designs that are open for extension and closed for modification.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the Liskov Substitution Principle (LSP)?

A

Objects of a superclass should be replaceable with objects of its subclasses without altering the correctness of the program.

Ensures polymorphism is safe.

17
Q

What does violating the Liskov Substitution Principle (LSP) typically cause?

A

Programs will behave incorrectly when using derived classes.

18
Q

How does Test-Driven Development (TDD) support Liskov Substitution Princple (LSP)?

A

TDD enforces LSP by making you write tests that validate subclass behavior matches superclass expectations. If a subclass breaks those expectations, tests will fail.

19
Q

What is the Interface Segregation Principle (ISP)?

A

Clients should not be forced to depend on interfaces they do not use.

20
Q

How does Test-Driven Development (TDD) support Interface Segregation Principle (ISP)?

A

TDD forces you to write interfaces around real, testable behaviors. If an interface is too large, writing focused tests becomes hard.

21
Q

What is the Dependency Inversion Principle (DIP)?

A

High-level classes should depend on interfaces or abstract classes, not concrete implementations.

Classes should depend on interfaces, not other classes.

22
Q

How is Loose Coupling a good technique for applying Dependency Inversion Principle (DIP)?

A

Loose coupling means classes depend on interfaces or abstract classes, not on concrete classes.

This satisfies DIP because high-level classes interact with abstractions, and low-level classes implement those abstractions.

23
Q

What is Dependency Injection (DI) and how does it apply Dependency Inversion Principle (DIP)?

A

Giving an object its dependencies from the outside instead of the object creating them itself.

This applies to DIP because classes depend on abstractions (interfaces) instead of concrete implementations.

24
Q

What is Inversion of Control (IoC) and how does it apply Dependency Inversion Principle (DIP)?

A

Object creation and dependency management is moved out of the class itself.

Applies DIP because classes depend only on abstractions, not on concrete implementations

25
How does Test-Driven Development (TDD) support Dependency Inversion Principle? (DIP)
TDD pushes you to design classes that depend on interfaces, not concrete classes, so you can easily mock dependencies in tests which naturally enforces DIP.
26
What is "Change Happens" referring to in software development?
All systems evolve over time; this must be anticipated when designing systems.