Creating Payment Microservice, Cron and Webhooks Flashcards
What is the Repository Pattern?
The Repository Pattern is a design pattern that abstracts the logic for data access and manipulation, providing a consistent interface for accessing data regardless of the actual data source.
What is the purpose of the Repository Pattern?
The main purpose is to centralize and isolate the logic for data access, allowing the rest of the application to interact with data through a uniform interface, enhancing testability and maintainability.
How does the Repository Pattern work?
It provides an intermediary layer between the application and the data source, containing methods for querying, adding, updating, and deleting data without exposing the underlying data access details.
What are the key components of the Repository Pattern?
Components include:
Interface: Defines the contract for data access methods.
Implementation: Provides the concrete implementation of these methods.
Data Source: The actual storage or database where data is retrieved or manipulated.
What benefits does the Repository Pattern offer?
Benefits include:
Abstraction: Hides complexities of data access logic.
Centralization: Provides a single point of entry for data operations.
Testability: Allows easy mocking for unit tests.
Flexibility: Allows for swapping data sources without affecting the application logic.
Is the Repository Pattern specific to certain programming languages or frameworks?
No, the pattern can be implemented in various programming languages and frameworks as a way to abstract data access logic.
When is the Repository Pattern particularly useful in software development?
It’s useful in applications where there are multiple data sources or when there’s a need for a clean separation between business logic and data access logic.
The Repository Pattern serves as a valuable architectural pattern for managing data access logic, promoting modularity, maintainability, and flexibility in software development.
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier used to uniquely identify information or objects in computer systems.
How is a UUID represented?
It is commonly represented as a 32-character hexadecimal string separated by hyphens, organized in five groups: 8-4-4-4-12 characters.
What are the characteristics of a UUID?
UUIDs are designed to be unique across time and space, generated using algorithms that ensure extremely low probability of collisions.
Why are UUIDs used in software development?
They are used to uniquely identify entities or resources, avoiding conflicts in distributed systems and providing a reliable way to reference information.
Can UUIDs be generated in different versions?
Yes, UUIDs can be generated in several versions (such as Version 1 to Version 5) based on different algorithms and input parameters.
What are the commonly used versions of UUIDs?
Common versions include:
Version 1: Based on time and MAC address.
Version 4: Generated from random or pseudo-random numbers.
Version 5: Using a hash of a namespace and name.
In what scenarios are UUIDs particularly useful?
UUIDs are beneficial in distributed systems, databases, or when creating unique identifiers without relying on centralized generation.
Are UUIDs always guaranteed to be unique?
While UUIDs are designed to be highly unique, the possibility of collisions is extremely low but not impossible, especially when using certain versions or inadequate generation methods.
UUIDs serve as reliable and widely adopted identifiers, ensuring uniqueness across systems and applications, contributing to the integrity and scalability of software systems.
What is a Mapped Superclass in JPA?
A Mapped Superclass is a class annotated with @MappedSuperclass in JPA that contains persistent state and mappings but isn’t mapped to a specific database table.
What’s the purpose of a Mapped Superclass?
It provides reusable mappings and fields shared among multiple entity classes, avoiding code duplication and ensuring consistent mapping logic across entities.
How does a Mapped Superclass differ from a regular entity in JPA?
A Mapped Superclass cannot be queried independently as it’s not an entity itself. Instead, its attributes and mappings are inherited by entities that extend it.
Can instances of a Mapped Superclass be persisted to the database?
No, instances of a Mapped Superclass cannot be directly persisted. Only entities that inherit from the Mapped Superclass can be persisted.
What annotations are commonly used with a Mapped Superclass?
Annotations like @MappedSuperclass, @Column, @Id, @GeneratedValue, and others can be used within the Mapped Superclass to define shared mappings and properties.
Why is a Mapped Superclass useful in JPA?
It promotes code reusability, allowing developers to define common attributes, relationships, or mapping configurations in a central place that can be inherited by multiple entities.
Can a Mapped Superclass be abstract or concrete?
Yes, a Mapped Superclass can be either abstract (providing only the structure) or concrete (with implementations for methods).
When is it appropriate to use a Mapped Superclass?
It’s beneficial when multiple entities share common attributes or mappings that should be defined in one place to maintain consistency and avoid redundancy.
Mapped Superclasses in JPA offer a convenient way to manage shared attributes and mappings among entities, enhancing code organization and maintainability in database-driven applications.
What is a joined table in database terminology?
A joined table is a virtual table created by combining rows from two or more tables using SQL JOIN operations based on related columns.
How is a joined table created?
It’s created using SQL JOIN statements, specifying the tables to join and the join conditions (e.g., INNER JOIN, LEFT JOIN, RIGHT JOIN) based on common columns.
What’s the purpose of a joined table?
It allows for querying data from multiple tables simultaneously, retrieving related information, and presenting it in a single result set based on specific join conditions.
What types of JOIN operations are commonly used to create joined tables?
Common JOIN types include:
INNER JOIN: Returns rows that have matching values in both tables.
LEFT JOIN (or LEFT OUTER JOIN): Returns all rows from the left table and the matched rows from the right table.
RIGHT JOIN (or RIGHT OUTER JOIN): Returns all rows from the right table and the matched rows from the left table.
What are the benefits of using joined tables?
Joined tables allow for efficient retrieval of related data, reduce data redundancy, and support complex queries involving multiple tables.