On 25 January 2013 22:29, Casey Ransberger <[hidden email]> wrote:
> Inline, briefly. > > On Jan 25, 2013, at 1:55 PM, Frank Shearar <[hidden email]> wrote: > >> By "stub out stuff" do you mean "write a stub test case with self >> assert: false"? *raises hand* > > Actually, I do that when I'm feeling responsible, as in I-might-want-to-use-this-more-than-once. More often though, I'm dinking around on Project Euler and plan to throw my code away, in which case I just paste in "self break." > >> Annoyingly, defining a #subclassResponsibility method destroys my >> flow: the debugger won't, obviously, prompt you for that "create >> method" button I love so much. (Hm, could one restore that with a >> SubclassResponsibilityException that the debugger can catch?) > > I'm not sure what the right way to do that would be, but I feel your pain. Try it? So actually the UI part is really easy, thanks to Debugger >> #buildNotifierWith:label:message:. I now have a nice Create button, it calls the correct method... but I'm a bit stumped. I can record in the call of "self subclassResponsibility" the class and selector that needs implementing (stored in a SubclassResponsibilityError), and this causes the debugger to pop up... but I don't know how to get a handle on the SubclassResponsibilityError itself to find out what to do. Any ideas? (I've scratched around a fair bit with exception handling and the Debugger, but this is one step beyond me right now.) frank |
> -----Original Message----- > From: [hidden email] [mailto:squeak-dev- > [hidden email]] On Behalf Of Frank Shearar > > On 25 January 2013 22:29, Casey Ransberger <[hidden email]> > wrote: > > Inline, briefly. > > > > On Jan 25, 2013, at 1:55 PM, Frank Shearar <[hidden email]> > wrote: > > > >> By "stub out stuff" do you mean "write a stub test case with self > >> assert: false"? *raises hand* > > > > Actually, I do that when I'm feeling responsible, as in > more-than-once. More often though, I'm dinking around on Project Euler and > plan to throw my code away, in which case I just paste in "self break." > > > >> Annoyingly, defining a #subclassResponsibility method destroys my > >> flow: the debugger won't, obviously, prompt you for that "create > >> method" button I love so much. (Hm, could one restore that with a > >> SubclassResponsibilityException that the debugger can catch?) > > > > I'm not sure what the right way to do that would be, but I feel your pain. Try > it? > > So actually the UI part is really easy, thanks to Debugger >> > #buildNotifierWith:label:message:. I now have a nice Create button, it calls the > correct method... but I'm a bit stumped. I can record in the call of "self > subclassResponsibility" the class and selector that needs implementing (stored in > a SubclassResponsibilityError), and this causes the debugger to pop up... but I > don't know how to get a handle on the SubclassResponsibilityError itself to find > out what to do. > > Any ideas? (I've scratched around a fair bit with exception handling and the > Debugger, but this is one step beyond me right now.) Hi Frank, I'm not sure I understand what you are having trouble with, but if I needed to build a specific handler for subclassResponsibility I would create a new class: Error subclass: #SubclassResponsibilityError ... You could then change Object>> subclassResponsibility "This message sets up a framework for the behavior of the class' subclasses. Announce that the subclass should have implemented this message." self error: 'My subclass should have overridden ', thisContext sender selector printString To: Object>> subclassResponsibility "This message sets up a framework for the behavior of the class' subclasses. Announce that the subclass should have implemented this message." SubclassResponsibilityError new parentClass: thisContext sender; methodSelector: thisContext sender selector printString; signal: 'My subclass should have overridden ', thisContext sender selector printString. Now you can build a handler to do whatever you want it to do. That will give you a specific error object for this type of error. Does that answer your question? All the best, Ron Teitelbaum > > frank > |
Something about the subject line of this message prompted me to address
a long overlooked deficiency in the interpersonal communication aspects of our work, hence Kernel-dtl.732.mcz in the inbox. Just a joke, I'll move it to treated inbox shortly. ;-) Dave On Sat, Jan 26, 2013 at 07:23:52PM -0500, Ron Teitelbaum wrote: > > > > -----Original Message----- > > From: [hidden email] [mailto:squeak-dev- > > [hidden email]] On Behalf Of Frank Shearar > > > > On 25 January 2013 22:29, Casey Ransberger <[hidden email]> > > wrote: > > > Inline, briefly. > > > > > > On Jan 25, 2013, at 1:55 PM, Frank Shearar <[hidden email]> > > wrote: > > > > > >> By "stub out stuff" do you mean "write a stub test case with self > > >> assert: false"? *raises hand* > > > > > > Actually, I do that when I'm feeling responsible, as in > I-might-want-to-use-this- > > more-than-once. More often though, I'm dinking around on Project Euler and > > plan to throw my code away, in which case I just paste in "self break." > > > > > >> Annoyingly, defining a #subclassResponsibility method destroys my > > >> flow: the debugger won't, obviously, prompt you for that "create > > >> method" button I love so much. (Hm, could one restore that with a > > >> SubclassResponsibilityException that the debugger can catch?) > > > > > > I'm not sure what the right way to do that would be, but I feel your > pain. Try > > it? > > > > So actually the UI part is really easy, thanks to Debugger >> > > #buildNotifierWith:label:message:. I now have a nice Create button, it > calls the > > correct method... but I'm a bit stumped. I can record in the call of "self > > subclassResponsibility" the class and selector that needs implementing > (stored in > > a SubclassResponsibilityError), and this causes the debugger to pop up... > but I > > don't know how to get a handle on the SubclassResponsibilityError itself > to find > > out what to do. > > > > Any ideas? (I've scratched around a fair bit with exception handling and > the > > Debugger, but this is one step beyond me right now.) > > Hi Frank, > > I'm not sure I understand what you are having trouble with, but if I needed > to build a specific handler for subclassResponsibility I would create a new > class: > > Error subclass: #SubclassResponsibilityError > ... > > You could then change > > Object>> subclassResponsibility > "This message sets up a framework for the behavior of the class' > subclasses. > Announce that the subclass should have implemented this message." > > self error: 'My subclass should have overridden ', thisContext > sender selector printString > > To: > > Object>> subclassResponsibility > "This message sets up a framework for the behavior of the class' > subclasses. > Announce that the subclass should have implemented this message." > SubclassResponsibilityError new > parentClass: thisContext sender; > methodSelector: thisContext sender selector printString; > signal: 'My subclass should have overridden ', thisContext > sender selector printString. > > Now you can build a handler to do whatever you want it to do. That will > give you a specific error object for this type of error. > Does that answer your question? > > All the best, > > Ron Teitelbaum > > > > > frank > > > > |
In reply to this post by Ron Teitelbaum
On 27 January 2013 00:23, Ron Teitelbaum <[hidden email]> wrote:
> > >> -----Original Message----- >> From: [hidden email] [mailto:squeak-dev- >> [hidden email]] On Behalf Of Frank Shearar >> >> On 25 January 2013 22:29, Casey Ransberger <[hidden email]> >> wrote: >> > Inline, briefly. >> > >> > On Jan 25, 2013, at 1:55 PM, Frank Shearar <[hidden email]> >> wrote: >> > >> >> By "stub out stuff" do you mean "write a stub test case with self >> >> assert: false"? *raises hand* >> > >> > Actually, I do that when I'm feeling responsible, as in > I-might-want-to-use-this- >> more-than-once. More often though, I'm dinking around on Project Euler and >> plan to throw my code away, in which case I just paste in "self break." >> > >> >> Annoyingly, defining a #subclassResponsibility method destroys my >> >> flow: the debugger won't, obviously, prompt you for that "create >> >> method" button I love so much. (Hm, could one restore that with a >> >> SubclassResponsibilityException that the debugger can catch?) >> > >> > I'm not sure what the right way to do that would be, but I feel your > pain. Try >> it? >> >> So actually the UI part is really easy, thanks to Debugger >> >> #buildNotifierWith:label:message:. I now have a nice Create button, it > calls the >> correct method... but I'm a bit stumped. I can record in the call of "self >> subclassResponsibility" the class and selector that needs implementing > (stored in >> a SubclassResponsibilityError), and this causes the debugger to pop up... > but I >> don't know how to get a handle on the SubclassResponsibilityError itself > to find >> out what to do. >> >> Any ideas? (I've scratched around a fair bit with exception handling and > the >> Debugger, but this is one step beyond me right now.) > > Hi Frank, > > I'm not sure I understand what you are having trouble with, but if I needed > to build a specific handler for subclassResponsibility I would create a new > class: > > Error subclass: #SubclassResponsibilityError > ... > > You could then change > > Object>> subclassResponsibility > "This message sets up a framework for the behavior of the class' > subclasses. > Announce that the subclass should have implemented this message." > > self error: 'My subclass should have overridden ', thisContext > sender selector printString > > To: > > Object>> subclassResponsibility > "This message sets up a framework for the behavior of the class' > subclasses. > Announce that the subclass should have implemented this message." > SubclassResponsibilityError new > parentClass: thisContext sender; > methodSelector: thisContext sender selector printString; > signal: 'My subclass should have overridden ', thisContext > sender selector printString. > > Now you can build a handler to do whatever you want it to do. That will > give you a specific error object for this type of error. > Does that answer your question? > > All the best, > > Ron Teitelbaum Hi Ron, I've done exactly that, actually - that's the easy part :) So on the Debugger side there's the existing #createMethod. I've added a hook that will, on a SubclassResponsibilityError, add a button that triggers a new method, Debugger >> #createOverridingMethod. My problem is that with #createMethod you find out the name of the missing selector by getting self contextStackTop tempAt: 1.. And that's exactly the trick, I suspect: Object >> #subclassResponsibility | exception | exception := SubclassResponsibilityError blah. exception signal. That allows you to access the exception itself (and hence the info it stores) through self contextStackTop tempAt: 1. Thanks! frank >> frank >> > > > |
Free forum by Nabble | Edit this page |