General Flashcards

1
Q

What are pros of Monolith?

A
  • more simple. easy to develop, test and deploy as all services in single codebase.
  • performance. faster communication between since in the same process and memory space. no network latency
  • centralized logging, monitoring, debugging
  • easier to manage version and dependencies
  • transaction management. easy to manage transaction as in the same application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are cons of Monolith?

A
  • Scalability. hard to scale individual service
  • Resource utilization may be inefficient
  • deployment. single bug can bring down entire application. longer deployment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are pros of Microservices?

A
  • Independent scaling
  • Resource efficiency
  • Technology flexibility
  • Independent deployment
  • Fault isolation
  • Parallel development
  • Fast deployment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are cons of Microservices?

A
  • Maintaining distributed system is more complex
  • Inter services communication latency
  • Transaction management
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is race condition?

A

A race condition occurs in a multithreaded or parallel program when two or more threads or processes access shared resources or variables concurrently, and the final outcome depends on the unpredictable timing or order of their execution. This can lead to unpredictable behavior, errors, or bugs that are difficult to reproduce and diagnose.

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

What is deadlock?

A

A deadlock is a situation in concurrent programming where two or more processes or threads are unable to proceed because each is waiting for the other to release a resource they need.

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

What is functional programming?

A

A programming paradigm that treats computation as the evaluation of mathematical functions and avoids changing state and mutable data. It emphasizes the use of pure functions, immutability, and declarative code, contrasting with the imperative programming paradigm.

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

What key concepts of functional programming?

A
  1. Focus on Functions:
    • FP revolves around the concept of functions as the primary building blocks of computation.
    • Functions are treated as first-class citizens, meaning they can be passed around as arguments, returned from other functions, and assigned to variables.
  2. Immutable Data:
    • Data in FP is typically immutable, meaning once it’s created, it cannot be changed. Instead, new data structures are created.
    • Immutability avoids side effects and makes programs more predictable and easier to reason about.
  3. Avoidance of State:
    • FP emphasizes avoiding mutable state and side effects. Functions operate solely on their inputs, producing predictable outputs without modifying external state.
  4. Declarative Style:
    • FP promotes a declarative programming style where programs are written by describing what should be computed rather than how it should be computed.
    • This leads to concise and readable code that focuses on transformations of data through function composition.
  5. Recursion:
    • Recursion is often used instead of looping constructs for repetitive tasks in FP. Recursive functions are a fundamental concept for iteration.
  6. Pure Functions:
    • Pure functions have no side effects and always produce the same output for a given input, making them easy to test and reason about.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What key concepts of object oriented programming?

A
  1. Focus on Objects:
    • OOP revolves around the concept of objects, which encapsulate data (attributes) and behavior (methods) together.
    • Objects interact with each other through messages (method calls).
  2. Encapsulation:
    • Encapsulation is a key principle in OOP, where objects hide their internal state and expose a public interface for interacting with other objects.
  3. Inheritance:
    • Inheritance allows classes (blueprints for objects) to inherit behavior (methods) and attributes from parent classes, promoting code reuse and hierarchy.
  4. Polymorphism:
    • Polymorphism enables objects of different classes to be treated as objects of a common superclass through method overriding and method overloading.
  5. State and Identity:
    • OOP manages state and identity of objects, allowing objects to change their internal state over time (mutability).
  6. Design Patterns:
    • OOP commonly uses design patterns like Factory, Singleton, Observer, and others to solve recurring design problems effectively.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is diff functional vs object oriented programming?

A

Key Differences:
* Approach to Problem-Solving:
* FP focuses on transforming data through the composition of pure functions without mutable state.
* OOP emphasizes modeling real-world entities as objects with state and behavior, enabling abstraction and encapsulation.
* Mutability:
* FP encourages immutability and avoids mutable state to prevent side effects.
* OOP allows mutable state within objects, which can lead to more complex interactions and potential side effects.
* Core Concepts:
* FP revolves around functions, higher-order functions, and function composition.
* OOP revolves around classes, objects, inheritance, encapsulation, and polymorphism.

Choosing Between FP and OOP:
* Use Functional Programming When:
* Dealing with transformations of data.
* Avoiding mutable state and side effects.
* Emphasizing concurrency and parallelism.
* Use Object-Oriented Programming When:
* Modeling real-world entities and interactions.
* Encapsulating data and behavior within objects.
* Promoting code reusability through inheritance and polymorphism.

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

What is SOLID?

A

SOLID is an acronym that represents a set of principles for writing clean, maintainable, and scalable object-oriented code.

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

What keys of SOLID?

A
  1. Single Responsibility Principle (SRP)
    * Definition: A class should have only one reason to change, meaning it should have only one responsibility or job within the system.
    * Benefits: Promotes modularity, maintainability, and testability by keeping classes focused on specific tasks.
  2. Open/Closed Principle (OCP)
    * Definition: Software entities (classes, modules, functions, etc.) should be open for extension but closed for modification. This means that you should be able to extend the behavior of a module without modifying its source code.
    * Benefits: Encourages code reuse, reduces the risk of introducing bugs in existing code, and promotes scalable and flexible designs.
  3. Liskov Substitution Principle (LSP)
    * Definition: Objects of a superclass should be replaceable with objects of its subclasses without affecting the correctness of the program.
    * Benefits: Ensures interoperability of object types, promotes polymorphism, and helps maintain consistency in behavior across inheritance hierarchies.
  4. Interface Segregation Principle (ISP)
    * Definition: Clients should not be forced to depend on interfaces they do not use. This principle advocates for small, cohesive interfaces tailored to specific client needs.
    * Benefits: Prevents the creation of “fat” interfaces that impose unnecessary dependencies on clients, leading to more modular and maintainable code.
  5. Dependency Inversion Principle (DIP)
    * Definition: High-level modules should not depend on low-level modules. Both should depend on abstractions (e.g., interfaces). Additionally, abstractions should not depend on details; details should depend on abstractions.
    * Benefits: Reduces coupling between modules, promotes code flexibility and extensibility, and facilitates the application of other SOLID principles.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly