|
-
Apr 8th, 2008, 11:25 AM
#1
Thread Starter
Frenzied Member
.NET Bubbling
Learned it today. c00l
-
Apr 8th, 2008, 11:15 PM
#2
Hyperactive Member
Re: .NET Bubbling
And what, dare I ask, is Bubbling supposed to be?
-
Apr 8th, 2008, 11:43 PM
#3
Re: .NET Bubbling
Agreed, I have no clue either..
-
Apr 8th, 2008, 11:45 PM
#4
Hyperactive Member
Re: .NET Bubbling
That goodness. I was beginning to think that I know nothing about programming. (Not that I do... but anyway)
-
Apr 9th, 2008, 01:12 AM
#5
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
-
Apr 9th, 2008, 01:24 AM
#6
Hyperactive Member
Re: .NET Bubbling
Like "try", "catch" and "throw"?
-
Apr 9th, 2008, 02:20 AM
#7
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.
-
Apr 9th, 2008, 02:20 AM
#8
Thread Starter
Frenzied Member
Re: .NET Bubbling
 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.
-
Apr 9th, 2008, 05:57 AM
#9
Re: .NET Bubbling
Bubbling is a new name for WM_NOTIFY
-
Apr 9th, 2008, 06:01 AM
#10
Hyperactive Member
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?
-
Apr 9th, 2008, 06:34 AM
#11
Re: .NET Bubbling
True, especially if we're talking about multithreaded applications.
-
Apr 9th, 2008, 06:48 AM
#12
Re: .NET Bubbling
 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.
-
Apr 9th, 2008, 07:30 AM
#13
Thread Starter
Frenzied Member
Re: .NET Bubbling
 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.
-
Apr 9th, 2008, 07:44 AM
#14
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
-
Apr 9th, 2008, 07:52 AM
#15
Re: .NET Bubbling
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
-
Apr 9th, 2008, 07:56 AM
#16
Thread Starter
Frenzied Member
Re: .NET Bubbling
 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?
-
Apr 10th, 2008, 02:41 PM
#17
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|