[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: retry does not work

T. Onoma

11/20/2003 11:02:00 AM

Guy:

> T> no, i wrote the library. ;) but i don't want interface code in it so i
> T> can resue it under differnt circumstances.
>
> Then change it : your need of resume in this case, just means that your
> library was badly designed

thats crap.

were taking about seperation of concerns --that's not bad design. i have a library i use for downloading files. i have a user interface script that uses the library. things happen in the library and if the user has set verbose more i should be able to report them to the user *without* having to write special esoteric message passing code.

sounds aweful dosen't it? come on, are you goating me?

-ts


2 Answers

ts

11/20/2003 11:05:00 AM

0

>>>>> "T" == T Onoma <transami@runbox.com> writes:

T> were taking about seperation of concerns --that's not bad design. i have
T> a library i use for downloading files. i have a user interface script
T> that uses the library. things happen in the library and if the user has
T> set verbose more i should be able to report them to the user *without*
T> having to write special esoteric message passing code.

You are raising an exception, this is, for me, different than sending
message to stdout

Guy Decoux

Charles Hixson

11/23/2003 4:00:00 PM

0

T. Onoma wrote:

>Guy:
>
>
>
>>T> ...
>> Then change it : your need of resume in this case...
>>
>>
>
>...i have a user interface script that uses the library. things happen in the library and if the user has set verbose more i should be able to report them to the user ...
>-ts
>
To me it seems that to handle this concern, the proper approach is to
raise the exception within the library, catch it within the library
(actually, within the same routine if possible), if you can't handle it
there, then print out your message and re-raise the exception. Of
course the "printing out of the message" could be handled via a call to
a custom "message handler" routine that serves your needs, so you have
extra place (probably within the library) to specialize things in a more
global way. "resume" is quite tricky if you don't know just where you
will be resuming to (consider what would happen to an external routine
that "resumed" a program structured as I'm proposing). I feel that
resume is normally best used within the same routine that threw the
exception, and that any other use is...dangerous. It is too likely that
later editing will introduce side effects without seeing the problems
that are being caused.