J
Jon
I am a little problem deciding when to use delegates and when not to. Is the
following a good example?
I have an order class and a messenger class (this does things like send
emails, pages, faxes). Currently we create the order and in the creation
function, we call other functions in sequence that do things that are not
order specific (other things may send emails besides the order being
created). Would it be better to create a delegate for the order creation
"event" and have the messenger class subscribe to it so it knows to send off
an email without the create function directly calling it? What's the real
benefit of doing that?
Example, an order is created like below...
***FormOrder
Private Sub CreateButton_Click()
Dim o as Order
o = new order (var,var,var)
End Sub
***FormOrder
Class Order
Function Create (foo,bar,boo) as String
insert some stuff into DB
'If needed, send an email
Messenger.CreateEmail (OrderNum, Time, etc)
Me.InsertCreatedLog(OrderNum, Time, etc)
Return OrderNum
End Function
End Class
Class Messenger
Public Shared Function CreateEmail ()
'Insert records into DB for the email processor to pick up
End Function
End Class
If using a delegate is the preferred way to go, can someone direct me to
some non-cryptic info on how to create the delegate and subscribe to/use it?
Thanks much
following a good example?
I have an order class and a messenger class (this does things like send
emails, pages, faxes). Currently we create the order and in the creation
function, we call other functions in sequence that do things that are not
order specific (other things may send emails besides the order being
created). Would it be better to create a delegate for the order creation
"event" and have the messenger class subscribe to it so it knows to send off
an email without the create function directly calling it? What's the real
benefit of doing that?
Example, an order is created like below...
***FormOrder
Private Sub CreateButton_Click()
Dim o as Order
o = new order (var,var,var)
End Sub
***FormOrder
Class Order
Function Create (foo,bar,boo) as String
insert some stuff into DB
'If needed, send an email
Messenger.CreateEmail (OrderNum, Time, etc)
Me.InsertCreatedLog(OrderNum, Time, etc)
Return OrderNum
End Function
End Class
Class Messenger
Public Shared Function CreateEmail ()
'Insert records into DB for the email processor to pick up
End Function
End Class
If using a delegate is the preferred way to go, can someone direct me to
some non-cryptic info on how to create the delegate and subscribe to/use it?
Thanks much