Proxy Patterns

The Proxy Design Pattern is a structural design pattern that provides an interface to another object while controlling access to it. Proxies can serve various purposes, such as controlling access, managing resource allocation, or adding additional functionality to an object without altering its interface. Types of Proxies Communication Proxy: Facilitates communication between objects that may be in different processes or environments, abstracting the complexities involved in remote method invocations. Logging Proxy: Adds logging capabilities to track method calls and interactions with the underlying object....

August 26, 2024 · 3 min · 541 words · Me

Singleton Pattern

The singleton design pattern ensures that a class has only one instance and provides a global point of access to that instance. This pattern is often used when exactly one object is needed to coordinate actions across the system, such as when managing shared resources like databases or configuration settings. Motivation The singleton pattern is motivated by scenarios where certain classes should only be instantiated once. Common examples include: Database Connections: You typically only want one instance of a database connection throughout the lifecycle of an application to avoid redundant connections and ensure consistent access to the data....

August 26, 2024 · 7 min · 1414 words · Me

Solid Principles

Single Responsibility Principle (SRP) The Single Responsibility Principle (SRP) is one of the five SOLID principles of object-oriented design and programming. It states that a class, module, or function should have only one reason to change, meaning it should have only one responsibility or job. This principle promotes the idea that a class should only have one reason to exist, encapsulating all the functionality related to that responsibility. Key Points of Single Responsibility Principle...

August 26, 2024 · 11 min · 2256 words · Me