Principles and Patterns in Software Design

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/48

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

49 Terms

1
New cards

Single Responsibility Principle (SRP)

A class should have only one reason to change, meaning it should do one thing.

2
New cards

Importance of SRP for maintainability

It promotes loose coupling and high cohesion, making code easier to maintain, test, and extend.

3
New cards

Sign of SRP violation

A class or method doing multiple unrelated things or long methods with different job sections.

4
New cards

Open-Closed Principle (OCP)

Software entities should be open for extension but closed for modification.

5
New cards

Achieving OCP in code

By using inheritance, interfaces, or patterns like Strategy to add new behavior without changing existing code.

6
New cards

Violation clue of OCP

Large switch or if/else statements growing with new cases.

7
New cards

Liskov Substitution Principle (LSP)

Subtypes must be substitutable for their base types without altering the program's correctness.

8
New cards

Example of LSP violation

A subclass overrides a method to throw an error or changes its meaning.

9
New cards

Interface Segregation Principle (ISP)

No client should be forced to depend on interfaces it doesn't use.

10
New cards

Signal of ISP violation

Classes implementing unused or dummy methods from large interfaces.

11
New cards

Dependency Inversion Principle (DIP)

High-level modules should not depend on low-level modules; both should depend on abstractions.

12
New cards

Benefits of DIP

It makes code more modular, testable, and easier to maintain.

13
New cards

Creational Design Patterns

Object creation mechanisms that improve flexibility and reuse.

14
New cards

Singleton pattern

Ensures a class has only one instance.

15
New cards

Factory Method pattern

It creates objects without specifying the exact class.

16
New cards

Builder pattern

Constructs complex objects step by step to avoid telescoping constructors.

17
New cards

Structural Design Patterns

Organizing classes and objects to form larger structures.

18
New cards

Adapter pattern

Converts one interface to another.

19
New cards

Decorator pattern

Adds behavior to objects dynamically at runtime.

20
New cards

Facade pattern

Simplifies complex systems by providing a unified interface.

21
New cards

Behavioral Design Patterns

Object interaction and responsibility delegation.

22
New cards

Observer pattern

A subject notifies multiple listeners about events or state changes.

23
New cards

Strategy pattern

Swapping algorithms at runtime to support OCP.

24
New cards

Command pattern

Encapsulates a request as an object, useful for undo/redo operations.

25
New cards

Bounded Context

A semantic boundary where a domain model applies and terms are well-defined.

26
New cards

Ubiquitous Language

A shared language used by developers and domain experts to ensure accurate code representation.

27
New cards

Domain Model

A conceptual model of the domain focused on essential behavior and knowledge.

28
New cards

Entity

An object with a unique identity that persists over time.

29
New cards

Value Object

An object defined only by its attributes, immutable and replaceable.

30
New cards

Aggregate

A group of related objects treated as a unit with a single root to ensure data integrity.

31
New cards

Domain Service

A stateless operation that performs actions and doesn't belong to any one entity or value object.

32
New cards

Domain Event

A significant event in the domain that triggers other actions.

33
New cards

Repository

Provides access to aggregates and abstracts away database interactions.

34
New cards

Concurrency

Performing multiple tasks seemingly at the same time.

35
New cards

Asynchronicity

Initiating a task and continuing execution without waiting for it to finish.

36
New cards

UI Responsiveness

It prevents the UI from freezing during long-running tasks.

37
New cards

Concurrency model based on event loops

Async/await - efficient for I/O-bound tasks on a single thread.

38
New cards

Thread-based concurrency model

Each task runs in its own thread, suitable for CPU-bound operations.

39
New cards

Coroutines

Lightweight functions that can pause and resume, used for concurrent operations.

40
New cards

Locks in concurrent systems

To prevent race conditions and ensure data consistency.

41
New cards

Fine-grained locking

Locks only a specific resource to maximize concurrency.

42
New cards

Coarse-grained locking

Locks larger resource sets, reducing concurrency but simplifying logic.

43
New cards

Transactional consistency

Ensuring database operations adhere to ACID properties under concurrency.

44
New cards

Common Coupling

Modules share access to the same global data or resources.

45
New cards

Temporal Coupling

One service relies on the timely response of another.

46
New cards

Domain Coupling

A necessary dependency due to the business domain.

47
New cards

Pass-through Coupling

A service relays data without understanding it, just to connect others.

48
New cards

Database bottlenecks

Limited connections, transactional overhead, and locking under load.

49
New cards

Runtime Architecture vs Code Structure

Runtime Architecture deals with system behavior during execution; Code Structure is about module organization and dependencies.