As for how they reduce work and save time.. In one of my apps, I have a SearchForm that displays the results of a search. Doubleclicking a line in the grid opens up that result in the relevant form that handles it.. be it the addresses screen, the invoices screen, the client screen.. whatever. Every screen in the app is searchable.
All the searchform does is have a delegate that is poked (and supplied with an argument as to what the user picked) when the user picks something
Now any form in my app can have a search.. The form prepares a query and hands it to the searchform. The form also registers a delegate association to a local method. The searchform runs the query and shows the results. It then delegates the picking of the result
As such, in my client form i can have a method called "ShowClient(searchPick as DataRow)", and in my address form I can have "ShowAddress(searchPick as DataRow)" - search form calls either of these depending on what was registered.
Without this, I would have to have all forms in my app descend from ASearchForm parent, which has a method "SearchResultChosen" and the searchform would have to know about the SearchableForm that owns it:
Dim s as New SearchForm(query, Me) 'pass reference to this form into the searchform
s.DoSearch()
...
and then in the searchform:
theSearchableForm.SearchResultPicked(grid.CurrentRow)
..
So yeah ,you say, that will work.. But what if I want my form to inherit from something else too? Why should all my forms have to inherit from searchableform just to be searchable.. They could implement an interface, but again, youre then forced to what to call the method. .What if a form is searchable in 2 ways, or has 2 searches? Then you run into a naming clash because you cant have 2 methods called the same name..
Think about how many click event handlers your average form has; lots! It would be a real headache if every button called a handler on a form that implemented the IClickHandler interface.. As it is, delegates allow us to call the methods nicer names:
OkButton_Click
CancelButton_Click
rather than:
ButtonCLickHandler(b as Button)
if b Is OkButton Then
'do OK routine
else if b is CancelButton Then
'do cancel routine..