-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create and use adapter subclass of Relational
that forwards to a parent object or to a data frame scan
#949
Comments
Example with
|
@Antonov548: Revised, the
|
According to ChatGPT, this is probably a variant of the "proxy" pattern. Perhaps a "router", but the typical use cases are a bit different from ours. The design pattern you are describing is commonly known as the Router Pattern or sometimes a Switch Pattern. It is a variant of the Proxy Pattern, specifically tailored for scenarios where the decision to delegate behavior to one of multiple instances is dynamic and based on some switching logic. Key Characteristics of This Pattern:
Example Use Cases:
Code Example:Here's an example in Python: from abc import ABC, abstractmethod
# Define the interface
class Service(ABC):
@abstractmethod
def perform_action(self, data):
pass
# Concrete implementations of the interface
class ServiceA(Service):
def perform_action(self, data):
print(f"ServiceA handling: {data}")
class ServiceB(Service):
def perform_action(self, data):
print(f"ServiceB handling: {data}")
# The Router (switching logic)
class ServiceRouter(Service):
def __init__(self, service_a: Service, service_b: Service):
self.service_a = service_a
self.service_b = service_b
def perform_action(self, data):
# Switching logic
if data.startswith("A"):
self.service_a.perform_action(data)
else:
self.service_b.perform_action(data)
# Usage
service_a = ServiceA()
service_b = ServiceB()
router = ServiceRouter(service_a, service_b)
router.perform_action("A123") # Routed to ServiceA
router.perform_action("B456") # Routed to ServiceB Related Design Patterns:
Let me know if you'd like to explore this further! |
Closes tidyverse/duckplyr#442.
The example below highlights the problem.
Implementation guide:
Relational
that takes an ALTREP data frame as an SEXPRelational
object to unconditionally forward to the parent relational object stored in the SEXPrel_project2()
andrel_filter2()
Relational
subclass in these new C++ functions...2()
functions are usedCreated on 2025-01-04 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: