Design Principles & OOP Design

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/14

encourage image

There's no tags or description

Looks like no tags are added yet.

15 Terms

1
New cards

What is KISS?

Keep it Simple, Stupid. We want to keep the simplest solution, rather than using a pattern for the sole purpose of using it. Only add complexity when simplicity stops working.

2
New cards

What is DRY?

Don't Repeat Yourself. For maintenance purposes, avoid rewriting the same logic in multiple places, have some common place similar logic can reference. Though, sometimes some duplication is completely fine, especially if the rules are unrelated.

3
New cards

What is YAGNI?

You Aren't Gonna Need It. We want to build what we want now and not anymore, while still keeping the extensibility of the system in consideration.

4
New cards

What is Separation of Concerns?

For extensibility and testability, no part of the code should handle different responsibilities at once.

5
New cards

What is the Principle of Least Knowledge?

Only directly provide to the user what they need, rather than exposing internal state (e.g., deep chaining).

6
New cards

What is SRP?

Single Responsibility Principle. Classes should only be responsible for one thing. This is to make changes isolated.

7
New cards

What is OCP?

Open/Closed Principle. Classes should generally be open for extenstion, but closed for modification. This only really applies when variation is known at the start.

8
New cards

How do you maintain a good balance between KISS and OCP?

Where variation is hypothetical, keeping your system simple isn't a bad thing, because you're building based on your current requirements without speculating complexity (e.g., a bad example would be an interface with a single implementation).

9
New cards

What is ISP?

Interface Segregation Principle. Keep your interfaces small & simple instead of making them large & general-purpose.

10
New cards

What is DIP?

Dependency Inversion Principle. Generally, high-level classes should depend on abstractions rather than conforming to concrete implementations (low-level details), especially when you want to ensure testability and flexibility.

11
New cards

What is encapsulation and its benefit?

Keeping the class' data private and letting the class control how the data is represented and interacted with. The benefit is predictability (invariants) by only allowing modifications through your own provided functions.

12
New cards

What is abstraction and its benefit?

Exposing only what's essential and hiding complex implementation details through simple interfaces. The benefit is both for class users (simple interface), and the developers (easily switching through implementations).

13
New cards

When do we generally need abstraction?

Anywhere the logic feels tightly coupled or the requirements suggest multiple approaches.

14
New cards

What is polymorphism and its benefit, and its cost?

Allows us to replace stuff like switching on types by calling the same method and allowing the concrete type to handle it. The benefit is a lot of flexibility and extensibility, cost is complexity.

15
New cards

What is inheritance?

Kinda useless, but, whenever we have a stable base class, with an implementation that multiple subclasses need, we might need it (i.e., have the derived classes inherit the behavior).