The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
3answers
126 views

Many different classes that need similar functionality. Best approach?

I have many (at the moment around 30) different message classes in an application I am creating. Each of these messages need to be serialized and deserialized. However, the process of serializing and ...
3
votes
2answers
99 views

Why aren't field-like events implemented as a list of delegates?

tl;dr: Why are field-like events implemented as a single delegate field? Wouldn't it be more straight-forward to use a list of delegates, thereby eliminating the null special case and avoiding all the ...
2
votes
1answer
256 views

Avoiding closures

I have a data structure in the form of a tree. Each node represents a cardboard box. The boxes can contain child boxes. public class CardboardBox { public int Id {get; set;} public int ...
0
votes
1answer
82 views

Is it ok for a for a View to dismiss itself?

Currently, I'm working on a project in which a view is dismissing itself. While talking to another programmer on the team for this project, he said that it's fine (in that it behaves correctly), but ...
1
vote
1answer
124 views

Generic delegates (C#) in Scala?

I wanted to know if there is an equivalent of the C# generic delegates in Scala. The reference website is: http://msdn.microsoft.com/en-us/library/dd233060.aspx I'm trying to make a complete ...
1
vote
1answer
357 views

Understanding C# Delegates Structure

I've been trying to understand C# delegates using Pro C# 5. In short, the author describes the motivation for delegates as a structured way of dealing with function pointers and callbacks or two-way ...
0
votes
0answers
28 views

Own Exception or Delegation design pattern to exit a program?

I am writing an application in Java which use MVC pattern design. I have 4 major classes: Main, Controller, Model, View. Main initialize the other three and run launchMenu() in a infinite loop, a ...
0
votes
0answers
192 views

Delegate method privately called from delegate itself?

One has established design patterns so ingrained in their brain, that when sometimes somebody does something unexpected, it is a revelation. My colleague in an iOS project did call the delegate ...
0
votes
1answer
59 views

Is it fine for a class that creates objects to delegate them?

I have a large list of intercommunicating components; so I decided to have one class create all of them and then subsequently delegate them to other classes to facilitate finer tweaking and wiring ...
2
votes
0answers
117 views

Run a function when a function in a list is executed?

Goal: I'm currently doing an MVC project and I have this method to update the ViewBag (based on previous actions of the user). I would like to call this function whenever a certain list of MVC Actions ...
5
votes
4answers
928 views

C# Delegates are immutable - but why does that matter?

This is a followup question to this other question. Background Working from the MSDN Delegates Tutorial (C#), I see the following: Note that once a delegate is created, the method it is ...
22
votes
7answers
5k views

Why would I ever use delegates if I'm not doing events? [duplicate]

I am trying to learn how to do events in C#, and according to the MSDN Events tutorial, Events are declared using delegates. If you have not yet studied the Delegates Tutorial, you should do so ...
4
votes
6answers
917 views

Do delegates defy OOP

I'm trying to understand OOP so I can write better OOP code and one thing which keeps coming up is this concept of a delegate (using .NET). I could have an object, which is totally self contained ...
3
votes
3answers
966 views

Why use protocol, not call the method directly?

I was asked this question in an interview. For eg: UITableviewDelegate protocol has CellForRowAtIndexpath. Why make it a delegate method in a protocol not a method in the UITableView class and call it ...
7
votes
2answers
10k views

What is Delegation and why is it important in iOS programming?

At the moment I am teaching myself iOS programming, and one concept I find really hard to wrap my head around is delegation. What is it? Why and how is it used? What is the advantage? The technical ...
2
votes
2answers
362 views

Template method within one class without subclasses or inheritance

I have an algorithm with mostly invariant parts that needs to be reused within one class so as to stay DRY. Code duplication with repeating method structure public void save(String key, int value) ...
6
votes
5answers
7k views

What are the advantages of the delegate pattern over the observer pattern?

In the delegate pattern, only one object can directly listen to another object's events. In the observer pattern, any number of objects can listen to a particular object's events. When designing a ...
6
votes
2answers
2k views

MVC and delegation

I am a beginning iOS programmer and use the Model-View-Controller model as a design pattern: my model doesn't know anything about my view (in order to make it compatible with any view), my view ...
2
votes
2answers
2k views

Strategy vs Delegates

Can the Strategy design pattern entirely replace delegates? In Java, for example, there are no delegates. Is it possible to gain all the features of delegates by using Strategy design pattern? ...
4
votes
1answer
769 views

Need to process 2 million 100k messages per second and route them to a particular event, delegate or multicast delegate

I need to process 2 million messages per second (perhaps in a scale out configuration) and route each message to a N delegates or multicast delegates. Question How should I structure my application ...
6
votes
2answers
443 views

Delegates and events

What is the difference between public delegate void SecondChangedHandler(Object clock, TimeInfoEventArgs ti); public event SecondChangedHandler OnSecondChanged; and public event ...
4
votes
2answers
1k views

How do delegates fit into ASP.NET?

A developer told me they used delegates to bind most of their events in ASP.NET. Until then, I did not even know it was possible to use delegates in ASP.NET in a meaningful way. My understanding ...
7
votes
4answers
396 views

Can you overuse delegates and events

I've just started getting to grips with event driven programming and I'm finding delegates and events to be very useful. Since starting to see the potential I've began using them all the time to solve ...
2
votes
5answers
277 views

Delegate vs Method

Is there any advantige using delegates instead of methods? For example: public void LoginAuthenticate(object sender, AuthenticateEventArgs e) { if (Membership.ValidateUser(lgUserLogin.UserName, ...
15
votes
5answers
2k views

How would you teach C# delegate to a newbie? [closed]

I was reviewing Andrew Troelsen book on C# 4.0. The part that explains delegates starts as smooth as: public class SimpleMath { //declare delegate public delegate int BinaryOp(int x, int y); ...
3
votes
2answers
612 views

Delegate pattern for retrieving data v.s. using simple setters

I am considering using the Delegate Pattern to get some data necessary for an operation. There are a few different pieces of data that the algorithm needs to run, but they all have default values that ...
9
votes
10answers
25k views

Real world use of C# Delegates [closed]

I think that I conceptually understand C# delegates, however, I am struggling to find a real world example where they would be useful. Can you provide some answers detailing how C# delegates were ...