Skip to main content

Questions tagged [delegation]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
3 answers

Are there any benefits to delegation over subclassing/inheritance in the case of a singleton?

Example: The MacOS API known as Cocoa uses Delegation to specify various behaviors within the app. A Delegate is a separate object that implements a set of methods that are called by an original ...
CPlus's user avatar
  • 1,189
0 votes
2 answers

Should an Express error handler be used to send HTTP 4xx responses?

In other words, should the raising of an HTTP 4xx code be considered an error, and should the job of sending an HTTP 4xx code to a client be delegated to an error handler? Or is it simpler to just ...
Asker's user avatar
  • 109
4 votes
1 answer

Delegate vs Forwarding in Java OOP

I'm reading some article about "prefer composition over inheritance", and heard about Forwarding and Delegation. After search for the different I found some source:
nhoxbypass's user avatar
11 votes
1 answer

Delegation pattern in Python: is it unpopular? Is it considered not Pythonic?

As a Ruby/Rails person, I often deal with method delegation. It's often convenient to delegate a method to a composed object or a constant. Ruby even has a def_delegator helper method to easily build ...
art-solopov's user avatar
-1 votes
1 answer

Should we delegate user input sanitization/validation?

Consider this code: new FrameworkClass( [ 'query' => $_POST[ 'input' ] ] ); FrameworkClass is supposed to do input sanitization and validation. Should we just trust 3rd party code to do it's job? ...
Hans's user avatar
  • 416
3 votes
2 answers

Alternatives to the delegation pattern allowing blind messages between components

Delegates and delegation exist to enable passing specific messages to an observer, regardless of that observer's type. In a coordinator-type architecture, where coordinators manage and run the flow of ...
barndog's user avatar
  • 131
9 votes
1 answer

Code Design: Delegation of arbitrary functions

On PPCG, we frequently have King of the Hill challenges, which pit different code bots against each other. We don't like limiting these challenges to a single language, so we do cross-platform ...
Nathan Merrill's user avatar
4 votes
1 answer

Extension versus Delegation

I am using Swift and am wondering about the concepts of Extension and Delegation. Recently I found a case where either one of these two concepts could be applied. This reminded of the "composition ...
Vince's user avatar
  • 141
3 votes
1 answer

How to DRY decorator pattern and other delegation in java

I was refactoring some java to use decorators. All of the decorators inherited from a class ThingDecorator, let's say. This consisted entirely of: SomeType methodName(OtherType otherThing) { ...
sqykly's user avatar
  • 219
6 votes
1 answer

Best practice to authenticate third party to a website?

I've a website built with ASP.NET, and uses Cookie based Forms Authentication to protect it self from unauthorized access. It also has a REST based API which uses API key based Authentication. (Key ...
BuddhiP's user avatar
  • 193
3 votes
1 answer

Do conditional delegation or different member types break the Composite pattern?

Here's how I understand the composite pattern: In the composite pattern, a root object is composed of objects which may be further composed. Moreover, to be considered composite, all those objects ...
kdbanman's user avatar
  • 1,457
2 votes
2 answers

Delegating work and programming to component interfaces

I have a MessageHandler class which receives and validates messages before determining which components in the architecture they should be delegated to so they can be processed. This involves calling ...
ksl's user avatar
  • 121
3 votes
1 answer

Language support for (syntactic) delegation in Java

Composition over inheritance is an old trend or even accepted state of the art in object oriented programming. It would be even easier to use in Java, if there were language support for delegation. ...
Harald's user avatar
  • 181
3 votes
2 answers

How to use scala case classes when delegation is needed

Let's assume in our application we want to model cars. We also want to model a car repository where we store some registered cars. How should that be modeled in scala? Here comes my approach: First, ...
valenterry's user avatar
  • 2,429
7 votes
1 answer

Why are Scala's Either and Option types not interfaces/traits but classes?

I wanted to create a class CompileResult, that can be treated like an Either type but has some additional useful methods. It should be a CompileSuccess or a CompileFailure (which, too, has some ...
valenterry's user avatar
  • 2,429