Software Engineering Flashcards

1
Q

How does version control, specifically Git, facilitate collaborative software development?

A

Git allows multiple developers to work on a project simultaneously, managing changes, merging, and maintaining a history of revisions.

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

What is the difference between a thread and a process?

A

A process is an independent program; a thread is a lightweight, independent unit of execution within a process.

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

How does a hash table work, and what is its time complexity for common operations?

A

A hash table uses a hash function to map keys to indices; time complexity for search, insertion, and deletion is generally O(1) on average.

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

Explain the concept of polymorphism in object-oriented programming.

A

Polymorphism allows objects to be treated as instances of their parent class, promoting code reusability and flexibility.

Animal. Make Sound

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

How does garbage collection work in programming languages like Java or JavaScript?

A

Garbage collection automatically identifies and removes unreferenced objects to free up memory.

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

Explain the concept of Dependency Injection in software design.

A

Dependency Injection facilitates loose coupling by injecting dependencies into a class rather than creating them internally.

const loggerInstance = new Logger();
const productService = new ProductService(loggerInstance); 
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of CORS (Cross-Origin Resource Sharing) in web development?

A

CORS allows or restricts web resources requested from a different domain, enhancing security and preventing unauthorized access.

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

Explain the concept of a closure in JavaScript.

A

A closure is a function that remembers the variables from its outer scope even after the outer function has finished executing.

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

How does the event loop work in JavaScript?

A

The event loop manages the execution of tasks in a non-blocking way

Call Stack: Executes synchronous tasks.

Web APIs & Callback Queue: Handle asynchronous tasks.

Event Loop: Monitors Call Stack and Callback Queue.

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

Explain the concept of a design pattern in software development

A

A design pattern is a reusable solution to a common problem in software design, providing a template for solving specific issues.

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

What is the purpose of the “this” binding in JavaScript arrow functions?

A

Arrow functions inherit the “this” value from their enclosing scope, eliminating the need for explicit binding.

Arrow functions in JavaScript lexically capture the this value, maintaining the context from their surrounding scope. This contrasts with regular functions, where this is dynamically determined, potentially leading to unexpected behavior.

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

Explain the concept of a NoSQL database, and provide an example.

A

NoSQL databases store and retrieve data using non-tabular models. Example: MongoDB, which uses a document-oriented model.

Explain the concept of a NoSQL database, and provide an example.

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

What is monolithic programming

A

Single Unified codebase

Django, WordPress

.Cons:Scalability challenges.Limited technology flexibility.Pros:Simplicity in development.Easier to manage in smaller projects.

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

4 advantages of Nodejs in comparison with Java

A

Asynchronous Nature:Event-driven, non-blocking

Unified Language:JavaScript for frontend and backend.

Fast Execution:V8 engine performance.

Lightweight and Fast Startup:Suitable for microservices and serverless. Less resources

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

3 advantages of using Java versus node JS

A

Enterprise-Level Scalability
Native Threads Support
Java Memory Model

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

what is grpc and its feature

A

Remote Procedure Call
- it’s open source by Google
- it uses HTTP 2 for transport
- protocol buffers (binary data transfer)
- it’s bio-directional streaming
- efficient for serialization
- it’s language agnostic
- microsevices communication

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

what’s Stateless nature in REST/GRPC/Graphql?

A
  • each request is independent
  • system do not maintain a session of client
  • it simplifies scalability.
  • Fault Tolerance: if one request fails you can direct it to other

stateful: websocket

18
Q

S,H,E,N,S

When use Rust instead of NodeJs

A
  • Systems Programming: Rust excels in low-level control and memory safety.
  • High-performance: Rust is suitable for heavy computation and data processing.
  • Embedded Systems: Rust is ideal for firmware and IoT devices.
  • Networking: Rust offers strong concurrency and memory safety for networking applications.
  • Security: Rust prevents common security vulnerabilities.
19
Q

R,R,P,E,A

When use Nodejs Instead of Rust

A
  • Rapid Prototyping: Node.js allows for quick development due to its simplicity and large ecosystem.
  • Real-time Web Applications: Node.js excels in building real-time applications like chat applications or streaming services.
  • Developer Productivity: Node.js has a lower learning curve and offers faster development cycles.
  • Rich Ecosystem: Node.js has a mature ecosystem with a wide range of libraries and frameworks.
  • Scripting and Automation: Node.js is well-suited for scripting tasks and automating workflows.
20
Q

Compare Rust and Nodejs Memory managment

A

Rust: based on system of ownership, borrowing, and lifetimes
NodeJs: uses automatic garbage collection to manage memory

-Rust is better in memory safety

21
Q

MySql Weaknesses and Strengths

A

Weaknesses:
- Limited support for advanced features
- scalability concerns.

Strengths:
- Widely used,
- open-source,
- good performance for small to medium-sized databases.

22
Q

Postgres Weaknesses and Strengths

A

Weaknesses:
- Can be slower for complex queries,
- higher memory usage

Strengths:
- Advanced features (e.g., JSON support, full-text search)
- strong ACID compliance.

  • set of properties that guarantee that database transactions are processed reliably:*
    Atomicity, Consistency, Isolation, and Durability.
23
Q

Oracle Database Weaknesses and Strengths

A

Weaknesses: Expensive licensing, complex setup and management.

Strengths: High performance, scalability, comprehensive feature set.

24
Q

SQL Server Weaknesses and Strengths

A

Weaknesses: Proprietary, limited cross-platform support.

Strengths: Integration with Microsoft ecosystem, strong security features.

25
Q

SQLite Weaknesses and Strengths

A

Weaknesses: Not suitable for high-concurrency environments, limited scalability.

Strengths: Zero-configuration, lightweight, embedded, suitable for mobile and small-scale applications.

26
Q

what’s microsevices?
3 benefities ?

3 tips in designing ?

https://medium.com/hashmapinc/the-what-why-and-how-of-a-microservices-architecture-4179579423a9

A

What
It involves developing small, loosely coupled services that can be deployed independently.

** pros** include 1- scalability, 2- fault isolation, and 3- the ability to choose the best technology for each service.

cons
- security - latency - harder to access data -maintaining - complexity, logging (stack tace)

Design tips
1- Avoid direct access to one database in services

2- Address service dependencies using API Gateways and Service Discovery tools.

4- Design services carefully to hide complexity and expose only necessary details.

27
Q

Pros & Cons of ORMS

A

Pros:
- increase productivity
- type-safty
- auto-completion
- less rigorous testing

Cons:
- missing DB features (leaky abstraction)

  • SQL stays the same, but ORMs have new abstraction which you need to learn
  • Vendor/library lock-in (making it difficult to switch to an alternative solution)
28
Q
A
29
Q

What’s DTO in software?

A

for storage, retrieval, serialization, validation

A Data Transfer Object is an object that is used to encapsulate data, and send it from one subsystem to another

30
Q

What’s JWT structure?

A

used of auth

1- header: type, hashing alg
2- payload: clams e.g a user
3- signature: encoded header/payload , signed with a secret

tips:
1- should be shrort
2- not senstive data inside

31
Q

What’s Idempotency?

A

Idempotency ensures that repeating an action yields the same result, regardless of how many times it’s executed. It’s crucial for reliability, scalability, and fault tolerance in distributed systems.

Solution?
Unique IDs:
1- Assign unique IDs to POST requests.Conditional Headers:
2- Use conditional headers to verify request conditions.

3- Consistent Modifications: Ensure API handles data modifications consistently.

32
Q

Functional programming vs inherentence

A

Functional programming:
1. Immutable Data: Data is immutable, leading to fewer side effects.
2. Higher-order Functions: Functions can take functions as arguments or return functions.
3. Pure Functions: Functions produce the same output for the same input, without modifying external state.
5. Concurrency: Easier to reason about and implement concurrent systems due to immutability.
6. Declarative Style: Focuses on what to do rather than how to do it, leading to concise code.

Inheritance:
1. Code Reusability: Allows classes to inherit attributes and methods from parent classes.
2. Hierarchical Structure: Supports the creation of class hierarchies for organizing code.
3. Polymorphism: Enables objects of different classes to be treated uniformly through inheritance.
4. Encapsulation: Encapsulates common behavior and attributes within parent classes.
5. Extensibility: Facilitates adding new functionality to existing classes without modifying their structure.
6. Dependency: Can lead to tight coupling between classes, making code harder to maintain and extend.

33
Q

4 questions in interview before answering a system design question?

A

Try to understand
1- usecases
2- scalability requirements
3- technical constraints

by
Scope and Requirements Clarification:

1 What are the specific requirements of the system?
Are there any constraints or limitations?
What are the expected user interactions or use cases?
Performance and Scalability:

2 What are the expected load and scalability requirements?
Are there any performance benchmarks or expectations?
What are the anticipated growth rates?
Availability and Reliability:

3 What are the uptime requirements?
How should the system handle failures or outages?
Are there any disaster recovery or backup requirements?
Data Management:

4 What types of data will the system handle?
What are the read and write patterns?
Are there any consistency or durability requirements?
Security and Compliance:

34
Q

Redis vs Memcached

A

Redis:

Supports complex data types
Offers persistence options
Advanced features like pub/sub and transactions
Versatile for various use cases

Memcached:

Stores data as key-value pairs
No persistence mechanism
Primarily for simple caching

35
Q

Kafka usecases?

A

enables organizations to handle real-time data effectively across various use cases.

  1. log processing and analysis (integrate with ELK stack > kibana)
  2. Data streaming for recommendations ( integrate with Flink > Machine learning)
  3. system monitoring and alerting
  4. changeed data capture (CDC) keeping sync data in multiple dbs
  5. system Migration from v1 to v2
36
Q

DDD

A

Domain-driven design (DDD) is an approach to software development that emphasizes understanding and modeling the core business domain, fostering collaboration between domain experts and developers, and creating a common language to describe the domain.

Strategic design

**-ubiquitous language **
- Domains :
1 - core domain: video streaming
2 - sub domains: recomandation/ billing

- key parts of each domain (billing)
Entities: subscriber / payment details, subscription plans

bounded context
subscribers in (billing/recommandation)

Context map with anti corruption layer
relationship and commiunication between domains/entities

Tactical design
domain objects:
- entity (mutable but ID) <—> realworld counterpart
- value objects (immutable) like email
- aggreate (several entity/value) e.g. order

Repositories and Services

37
Q

Kafka vs RabbitMQ

A
  • Protocol: publish-subscribe – message queuing
  • Scalability: high throughput and horizontal scalability — smaller-scale
  • use cases: real-time data streaming, analytics — task distribution, async messaging
  • consumer groups: consumer groups support, parallel processing of messages —- no builtin
  • Message ordering: multiple partitions , one queue
  • Message Priority: no priority, supports it
  • Replication with partition replication, with Mirrored Queue
  • Message Delivery Guarantees: atleast once and exactly once — at least one
    *
38
Q

The storage location of a refresh token?

A

Client-Side Storage - HTTP-only Cookies:
stored in a cookie that is flagged as HTTP-only, making it inaccessible to JavaScript.
Pros: Provides protection against cross-site scripting (XSS) attacks.
Cons: May still be vulnerable to cross-site request forgery (CSRF) attacks.

Server-Side Storage - Session Storage:
stored on the server, typically in a database or an in-memory store like Redis, and linked to the user’s session.
Pros: Enhances security by keeping the token out of the client’s hands.
Cons: Requires additional server-side infrastructure and management

39
Q

SOLID

A

Single Responsibility Principle (SRP): A class should have only one reason to change, meaning it should only have one job or responsibility.

  • example MVC, split in layers based on sRP

Open/Closed Principle (OCP): Software entities should be open for extension but closed for modification. You should be able to add new functionality without altering existing code.

Liskov Substitution Principle (LSP): Objects of a superclass should be replaceable with objects of a subclass without affecting the correctness of the program.

Interface Segregation Principle (ISP): Clients should not be forced to depend on interfaces they do not use. This means creating smaller, more specific interfaces rather than a single, general-purpose interface.

Dependency Inversion Principle (DIP): High-level modules should not depend on low-level modules. Both should depend on abstractions. Additionally, abstractions should not depend on details; details should depend on abstractions.

  • used a lot
  • testable
  • in construcure or function argument like s3client
    NestJs, sprint boot, scala by default
40
Q

when suggest to transition to microservices?

A
  • how to distribute your team (conway law)
  • avoid single point of failure
41
Q

sanity test vs smoke test

A

Sanity test: A quick validation check after after minor changes like bug fixes, often involving a small set of unit tests or basic functionality checks.

Smoke Test: Performed to verify that the overall system is stable enough for further testing. It checks the core functions of the entire system, often after a new build