All Questions
Tagged with delegation or delegates
63 questions
0 votes
2 answers
300 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
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 ~...
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 ...
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/...
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 ...
-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? ...
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 ...