Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

One of our contractors has left our company, and I have been unlucky enough to inherit his project. He was very experienced with VB6 and earlier, whereas I have only worked with VB.NET (for the last year or so) and C.

 

A lot of his code looks like this:

Public Event AddImage()
Private Sub HandleAddImage()
   RaiseEvent AddImage()
End Sub
Public Function Add(...) As Layer
   ....
   AddHandler MyLayer.AddImage, AddressOf HandleAddImage()
   ....
End Function
Public Sub Remove(...)
   ....
   RemoveHandleer MyLayer.AddImage, AddressOf HandleAddImage
   ....
End Sub

Could someone give me an idea of what this code is supposed to be doing? Is this a good way to write this code? It looks very wordy to me.

Posted

Hi...

 

In my opinion, and speaking about half a dozen lines of code, this is the way your ex-partner found to reuse his code...

 

Somewhere around you r code must be a sub called 'HandleAddImage' isn't it?

This way, whenever the 'MyLayer.AddImage' event occurs it call the ''HandleAddImage' method to handle it...

 

This coding method can be highlly usefull if you're managing several 'MyLayer' objects at the same time, so you don't have to repeat code...

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...