Software Engineering Flashcards
How does version control, specifically Git, facilitate collaborative software development?
Git allows multiple developers to work on a project simultaneously, managing changes, merging, and maintaining a history of revisions.
What is the difference between a thread and a process?
A process is an independent program; a thread is a lightweight, independent unit of execution within a process.
How does a hash table work, and what is its time complexity for common operations?
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.
Explain the concept of polymorphism in object-oriented programming.
Polymorphism allows objects to be treated as instances of their parent class, promoting code reusability and flexibility.
Animal. Make Sound
How does garbage collection work in programming languages like Java or JavaScript?
Garbage collection automatically identifies and removes unreferenced objects to free up memory.
Explain the concept of Dependency Injection in software design.
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);
What is the purpose of CORS (Cross-Origin Resource Sharing) in web development?
CORS allows or restricts web resources requested from a different domain, enhancing security and preventing unauthorized access.
Explain the concept of a closure in JavaScript.
A closure is a function that remembers the variables from its outer scope even after the outer function has finished executing.
How does the event loop work in JavaScript?
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.
Explain the concept of a design pattern in software development
A design pattern is a reusable solution to a common problem in software design, providing a template for solving specific issues.
What is the purpose of the “this” binding in JavaScript arrow functions?
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.
Explain the concept of a NoSQL database, and provide an example.
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.
What is monolithic programming
Single Unified codebase
Django, WordPress
.Cons:Scalability challenges.Limited technology flexibility.Pros:Simplicity in development.Easier to manage in smaller projects.
4 advantages of Nodejs in comparison with Java
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
3 advantages of using Java versus node JS
Enterprise-Level Scalability
Native Threads Support
Java Memory Model
what is grpc and its feature
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
what’s Stateless nature in REST/GRPC/Graphql?
- 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
S,H,E,N,S
When use Rust instead of NodeJs
- 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.
R,R,P,E,A
When use Nodejs Instead of Rust
- 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.
Compare Rust and Nodejs Memory managment
Rust: based on system of ownership, borrowing, and lifetimes
NodeJs: uses automatic garbage collection to manage memory
-Rust is better in memory safety
MySql Weaknesses and Strengths
Weaknesses:
- Limited support for advanced features
- scalability concerns.
Strengths:
- Widely used,
- open-source,
- good performance for small to medium-sized databases.
Postgres Weaknesses and Strengths
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.
Oracle Database Weaknesses and Strengths
Weaknesses: Expensive licensing, complex setup and management.
Strengths: High performance, scalability, comprehensive feature set.
SQL Server Weaknesses and Strengths
Weaknesses: Proprietary, limited cross-platform support.
Strengths: Integration with Microsoft ecosystem, strong security features.
SQLite Weaknesses and Strengths
Weaknesses: Not suitable for high-concurrency environments, limited scalability.
Strengths: Zero-configuration, lightweight, embedded, suitable for mobile and small-scale applications.
what’s microsevices?
3 benefities ?
3 tips in designing ?
https://medium.com/hashmapinc/the-what-why-and-how-of-a-microservices-architecture-4179579423a9
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.
Pros & Cons of ORMS
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)
What’s DTO in software?
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
What’s JWT structure?
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
What’s Idempotency?
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.
Functional programming vs inherentence
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.
4 questions in interview before answering a system design question?
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:
Redis vs Memcached
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
Kafka usecases?
enables organizations to handle real-time data effectively across various use cases.
- log processing and analysis (integrate with ELK stack > kibana)
- Data streaming for recommendations ( integrate with Flink > Machine learning)
- system monitoring and alerting
- changeed data capture (CDC) keeping sync data in multiple dbs
- system Migration from v1 to v2
DDD
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
Kafka vs RabbitMQ
- 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
*
The storage location of a refresh token?
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
SOLID
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
when suggest to transition to microservices?
- how to distribute your team (conway law)
- avoid single point of failure
sanity test vs smoke test
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