Questions tagged [delegates]
The delegates tag has no summary.
63 questions
0
votes
2
answers
301
views
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 ...
-2
votes
1
answer
168
views
Resorted to Unconventional( i.e., hacky) "circuitous" programming code techniques when using populating a list of C# Action Delegates via a for loop [closed]
AWS Amazon.S3.Model.PutObjectRequest is merely a 3rd-party AWS Data Transfer Object (DTO) / Plain Old C# Object (POCO) type that can be used to build a request that can be used to send requests to an ...
2
votes
1
answer
215
views
Functions vs Classes for delegate pattern
Please consider the following sample
#include <cstdio>
#include <functional>
#include <memory>
#include <utility>
class PaintDelegate {
public:
virtual ~...
2
votes
1
answer
203
views
How to refactor same block of delegate code into a single private method?
I have these lines in multiple test methods. Now, trying to create a private method to clean up but not sure how to do it. Any suggestion or pointer would be really helpful. Thanks.
var ...
38
votes
10
answers
10k
views
Why do heavily object-oriented languages avoid having functions as a primitive type?
As has been covered to the point of parody, heavily object-oriented languages, such as C# or Java, tend to lack the feature of having functions as a primitive type. You can argue about whether or not ...
0
votes
2
answers
63
views
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 ...
4
votes
1
answer
2k
views
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:
https://en.wikipedia.org/wiki/...
0
votes
2
answers
611
views
Turn an asynchronous delegate pattern into a blocking method
I have to use a built-in API that works like this
class MyAPIWrapper {
func callAPI() {
apiObj.delegate = self
apiObj.doWork() // returns immediately, eventually calls self.delegate....
13
votes
1
answer
5k
views
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 ...
0
votes
2
answers
548
views
Design issue with delegation, inheritance and dependency injection
My question relates to usage of delegation together with inheritance and dependency injection.
I have a MailerService class that requires a delegate in order to do its job.
Furthermore, I have a ...
-1
votes
1
answer
75
views
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?
...
2
votes
2
answers
4k
views
Fundamental differences between a List<Action> vs Action
Is there any fundamental difference between to using an action and a list of actions? Seeing that action is a delegate and therefore is a list itself. For instance:
List<Action> ...
0
votes
1
answer
342
views
How to generalize which delegate is being used from an interface
I currently have the following set up where I have 2 or 3 classes implementing IZoneController and I have a set of conditions determining which function they need to execute when called. I first ...
-1
votes
3
answers
450
views
Refactoring - Resolve dependencies between legacy code used by third parties
I am developing two libraries in .Net
Firs one it's a library with core functionality (named it Library.Core.dll)
Let's focus in User class
public class User
{
//set of constructors and ...