Problems with Passive Arguments and refactoring

Discussion in 'Ruby' started by Esteban Manchado Velázquez, Jan 18, 2005.

  1. Hi all,

    Sorry for breaking the thread, I mistakenly deleted the old message.

    The problem was: I did some code refactoring, and changed the number of
    arguments of some methods. I changed all the method calls.... except one or
    two. The thing is, the interpreter ate it up just fine, but the program
    crashed from time to time, and I had no idea why.

    Some hours later, I realized I had _not_ changed a couple of method calls,
    so the method was receiving undefined arguments, and doing some silly random
    thing until it crashed.

    That's it. Probably there are more problems, but that is what I recall it
    has happened to me (several times already, in fact), and one of the reasons
    I'm not particularly fond of Perl programming :)

    Regards,

    --
    Esteban Manchado Velázquez <> - http://www.foton.es
    EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es
    Esteban Manchado Velázquez, Jan 18, 2005
    #1
    1. Advertising

  2. On Monday 17 January 2005 07:08 pm, Esteban Manchado Velázquez wrote:
    | Hi all,
    |
    | Sorry for breaking the thread, I mistakenly deleted the old message.
    |
    | The problem was: I did some code refactoring, and changed the number of
    | arguments of some methods. I changed all the method calls.... except one or
    | two. The thing is, the interpreter ate it up just fine, but the program
    | crashed from time to time, and I had no idea why.
    |
    | Some hours later, I realized I had _not_ changed a couple of method
    | calls, so the method was receiving undefined arguments, and doing some
    | silly random thing until it crashed.
    |
    | That's it. Probably there are more problems, but that is what I recall
    | it has happened to me (several times already, in fact), and one of the
    | reasons I'm not particularly fond of Perl programming :)

    Not that you don't have a point. You do. But a number of things would catch
    errors "earlier" too, like static typing for example. But that's not Ruby's
    way. In general Ruby's philosophy is test first ( not that any of us do this
    most of the time, but we go back and pretend ;) In so doing these kinds of
    errors will usually get caught. So while you have an argument, (IMHO) I don't
    consider it a strong one.

    Thanks for the explanation,
    T.
    trans. (T. Onoma), Jan 18, 2005
    #2
    1. Advertising

  3. On Monday 17 January 2005 07:08 pm, Esteban Manchado Velázquez wrote:
    | Hi all,
    |
    | Sorry for breaking the thread, I mistakenly deleted the old message.
    |
    | The problem was: I did some code refactoring, and changed the number of
    | arguments of some methods. I changed all the method calls.... except one or
    | two. The thing is, the interpreter ate it up just fine, but the program
    | crashed from time to time, and I had no idea why.
    |
    | Some hours later, I realized I had _not_ changed a couple of method
    | calls, so the method was receiving undefined arguments, and doing some
    | silly random thing until it crashed.

    Oh, BTW, I know the feeling. Those days are hair pullers indeed!

    T.
    trans. (T. Onoma), Jan 18, 2005
    #3
  4. [OT] Re: Problems with Passive Arguments and refactoring

    "trans. (T. Onoma)" <> schrieb im Newsbeitrag
    news:...
    > On Monday 17 January 2005 07:08 pm, Esteban Manchado Velázquez wrote:
    > | Hi all,
    > |
    > | Sorry for breaking the thread, I mistakenly deleted the old message.
    > |
    > | The problem was: I did some code refactoring, and changed the number
    > of
    > | arguments of some methods. I changed all the method calls.... except one
    > or
    > | two. The thing is, the interpreter ate it up just fine, but the program
    > | crashed from time to time, and I had no idea why.
    > |
    > | Some hours later, I realized I had _not_ changed a couple of method
    > | calls, so the method was receiving undefined arguments, and doing some
    > | silly random thing until it crashed.
    >
    > Oh, BTW, I know the feeling. Those days are hair pullers indeed!
    >
    > T.


    LOL - No problem for me, I'm nearly bald. :))

    robert
    Robert Klemme, Jan 18, 2005
    #4
  5. --W/nzBZO5zC0uMSeA
    Content-Type: text/plain; charset=iso-8859-1
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable

    Hi T,

    On Tue, Jan 18, 2005 at 11:09:16AM +0900, trans. (T. Onoma) wrote:
    > [...]
    > | Some hours later, I realized I had _not_ changed a couple of method
    > | calls, so the method was receiving undefined arguments, and doing some
    > | silly random thing until it crashed.
    > [...]
    > Not that you don't have a point. You do. But a number of things would cat=

    ch=20
    > errors "earlier" too, like static typing for example.


    Yes, but I don't find parameter number checking slows you down, while
    static typing obviously does (at least in the short term).

    And I simply don't see the _advantage_ of not checking. If you need a
    variable arguments method, simply declare it as that.

    Also, IMHO if you push the dynamic philosophy too much, it stops being
    practical, because you put too much of a burden in the programmer (why the
    _need_ of testing for almost anything?). My _personal_ balance is having the
    language do things like parameter number checking, but allow more dynamic
    behaviour in other things (like parameter type checking).

    Regards,

    --=20
    Esteban Manchado Vel=E1zquez <> - http://www.foton.es
    EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es

    --W/nzBZO5zC0uMSeA
    Content-Type: application/pgp-signature; name="signature.asc"
    Content-Description: Digital signature
    Content-Disposition: inline

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.5 (GNU/Linux)

    iD8DBQFB7OywhYgK5b1UDsERAp8YAJ4vrzGUcmL8fvRV5p4wwxd+UMGLYACfdxdp
    aY8n6Q7rZRWatQdqR0eM51s=
    =a6fq
    -----END PGP SIGNATURE-----

    --W/nzBZO5zC0uMSeA--
    Esteban Manchado Velázquez, Jan 18, 2005
    #5
  6. On Tuesday 18 January 2005 06:02 am, Esteban Manchado Velázquez wrote:
    | Hi T,
    |
    | On Tue, Jan 18, 2005 at 11:09:16AM +0900, trans. (T. Onoma) wrote:
    | > [...]
    | >
    | > | Some hours later, I realized I had _not_ changed a couple of method
    | > | calls, so the method was receiving undefined arguments, and doing some
    | > | silly random thing until it crashed.
    | >
    | > [...]
    | > Not that you don't have a point. You do. But a number of things would
    | > catch errors "earlier" too, like static typing for example.
    |
    | Yes, but I don't find parameter number checking slows you down, while
    | static typing obviously does (at least in the short term).

    Okay, maybe a little. I don't think it slows people down too much. But I take
    your point. OTOH, having to use *args can slow one down too.

    | And I simply don't see the _advantage_ of not checking. If you need a
    | variable arguments method, simply declare it as that.

    The advantages are 1) greater polymorphism and 2) when doing AOP-style
    wrapping of multiple methods.

    | Also, IMHO if you push the dynamic philosophy too much, it stops being
    | practical, because you put too much of a burden in the programmer (why the
    | _need_ of testing for almost anything?). My _personal_ balance is having
    | the language do things like parameter number checking, but allow more
    | dynamic behaviour in other things (like parameter type checking).

    Sure. That's a fair opinion. But, in this case at least, I'm not of that
    opinion. I look at it as simple matter of duck quaking. For instance if I
    have:

    class A
    def a(x)
    "#{x}"
    end
    end

    class B
    def a(x,y)
    "#{x}#{y}"
    end
    end

    class C
    def puta(n,x,y)
    puts n.a(x,y)
    end
    end

    C.new.puta(B.new,"1","2") #=> 12
    C.new.puta(A.new,"1","2") #=> Error

    I don't think A#a should blow-up here --which it will. And to fix it one has
    to either put in a _dummy_ y parameter or use the less friendly *args.

    Wouldn't a special togglable warning be enough to catch'em if you did want to
    work this way? OTOH, mayb being able to simply specify a method as
    parameter-indeterminate, like:

    def *a(x,y)
    end

    Might do as well.

    T.
    trans. (T. Onoma), Jan 18, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    0
    Views:
    3,759
  2. jaems

    Passive mode

    jaems, Feb 18, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    419
    Scott Roberts
    Feb 19, 2008
  3. Pete Ashdown

    Passive getchar?

    Pete Ashdown, Jun 21, 2010, in forum: C Programming
    Replies:
    3
    Views:
    394
    Pete Ashdown
    Jun 22, 2010
  4. trans.  (T. Onoma)

    Passive Arguments

    trans. (T. Onoma), Jan 16, 2005, in forum: Ruby
    Replies:
    5
    Views:
    125
    benny
    Jan 17, 2005
  5. Hostile17

    Net::FTP and Passive mode problems

    Hostile17, Oct 20, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    183
    Sherm Pendley
    Oct 21, 2004
Loading...

Share This Page