Results 1 to 17 of 17

Thread: .NET Bubbling

  1. #1

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    .NET Bubbling

    Learned it today. c00l

  2. #2

  3. #3
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: .NET Bubbling

    Agreed, I have no clue either..

  4. #4

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: .NET Bubbling

    Bubbling is allowing events, information or processing to "bubble" back up to previous levels... typically with error handling, by allowing the error to bubble up back to a specific point, you can place a handler at the top level and catch it there. Sometimes this is good. Other times not so good. It just depends.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6

  7. #7
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: .NET Bubbling

    Yes, you'd only need to handle it in the container control/pages. If you want to and if it's relevant to your functionality.

  8. #8

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: .NET Bubbling

    Quote Originally Posted by BillGeek
    And what, dare I ask, is Bubbling supposed to be?

    Well I was experimenting yesterday about dynamically created user controls.

    I have this user control that encapsulates what it does. I've placed this on a page which has data that needs updating once an action is done on a user control.

    I've read about delegates however the control i'm dynamically creating is not declared as a specific instance in the page class but a generic "Control" so i'll have a hard time defining delegate handlers.

    The method for handling events should be straightforward.

    Basically I want the Page to be notified that "something" was done (whatever that is) on the user control and bubbling does that beautifully.

    Last edited by oceanebelle; Apr 9th, 2008 at 02:36 AM.

  9. #9
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: .NET Bubbling

    Bubbling is a new name for WM_NOTIFY

  10. #10
    Hyperactive Member BillGeek's Avatar
    Join Date
    Jun 2006
    Location
    Canada
    Posts
    440

    Re: .NET Bubbling

    And a new name for "On Error Goto ErrorHandler"...

    Seriously though... I DO see the point in using it. What I DON'T see is why? If I have a method, that invokes another method, that in turns invoke a third method, I would want to throw an error in the third method, not the "originating" method.

    Discuss?

  11. #11
    Frenzied Member MaximilianMayrhofer's Avatar
    Join Date
    Aug 2007
    Location
    IM IN YR LOOP
    Posts
    2,001

    Re: .NET Bubbling

    True, especially if we're talking about multithreaded applications.

  12. #12
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: .NET Bubbling

    Quote Originally Posted by BillGeek
    And a new name for "On Error Goto ErrorHandler"...

    Seriously though... I DO see the point in using it. What I DON'T see is why? If I have a method, that invokes another method, that in turns invoke a third method, I would want to throw an error in the third method, not the "originating" method.

    Discuss?
    The exception can be thrown anywhere, but it's really about where you handle it, isn't it? If you reference a third party class library, you'd rather handle the exception yourself rather than having the DLL handle it in its own way with, say, a log file. You may want all your exceptions in one place such as the event viewer.

  13. #13

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: .NET Bubbling

    Quote Originally Posted by BillGeek
    And a new name for "On Error Goto ErrorHandler"...
    Which gets me to wonder why .NET created "Exceptions" and just stuck to that for event generation?

    Catching exceptions is different from directing flow of the program, so I do not understand why bubbling is likened to it.

  14. #14
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: .NET Bubbling

    Because there's no guarantee that the error ocurrs in the same thread as the application that will handle it. The program flow can't cross threads (insert reference to 80's movie in which crossing streams is indicated to be a bad thing) so it has to be passed back up the chain some how, safely crossing from one thread to the next. Enter Delegates, which in essence an event handler. When the offending code burps, it throws a flag, and yells "HEY SOMETHING WENT S#$^ HERE!" ... and any one listening to that delegate (because it couldbe connected by more than one process) gets the notification that the thread has gone south and action needs to be taken.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  15. #15
    Super Moderator FunkyDexter's Avatar
    Join Date
    Apr 2005
    Location
    An obscure body in the SK system. The inhabitants call it Earth
    Posts
    7,957

    Re: .NET Bubbling

    Discuss?
    If you've got a method that can be called from several different places in your program, what constitutes an error in one of those places might be perfectly acceptable in another.

    For example, say you've got a function that finds the price of a given sales item. It's possible that the item won't be found in the inventory
    (e.g. it's been deleted). In one place it might be acceptable to just use a price of zero in this scenario, another part of your code might want to report the missing item to the user, a third might want to generate the missing item automatically. Your function doesn't have enough information to make that decision so you can't handle it there. Instead you need to let the calling code know that the item was missing and the easiest way to do that is to throw an exception up the stack.

    I have no idea if this is anything to do with 'Bubbling' but I'm right behind the try/throw/catch error handling aproach. It's far more powerful than trying to handle every error where it occurs.
    The best argument against democracy is a five minute conversation with the average voter - Winston Churchill

    Hadoop actually sounds more like the way they greet each other in Yorkshire - Inferrd

  16. #16

    Thread Starter
    Frenzied Member oceanebelle's Avatar
    Join Date
    Jun 2005
    Location
    my n00k.
    Posts
    1,064

    Re: .NET Bubbling

    Quote Originally Posted by techgnome
    Because there's no guarantee that the error ocurrs in the same thread as the application that will handle it. The program flow can't cross threads (insert reference to 80's movie in which crossing streams is indicated to be a bad thing) so it has to be passed back up the chain some how, safely crossing from one thread to the next. Enter Delegates, which in essence an event handler. When the offending code burps, it throws a flag, and yells "HEY SOMETHING WENT S#$^ HERE!" ... and any one listening to that delegate (because it couldbe connected by more than one process) gets the notification that the thread has gone south and action needs to be taken.

    -tg

    Is bubbling and the use of delegates the same?

    And of the three which is more expensive in terms of server resources used when one of them happens?

  17. #17
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: .NET Bubbling

    They are complementary, not different.

    You need a delegate to specify an event. Read.

    Whatever you do, it'll always be expensive, as it constitutes more cycles to perform your new code.

    As for error handling, if you're going to catch, handle and throw an error again, that too is quite expensive.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width