in reply to Re: Use globals or pass around everything under the sun?
in thread Use globals or pass around everything under the sun?

Im so glad you posted this. Its basically what I was going to say too.

Whenever I find I am dealing with large numbers of parameters getting passed around I create an object to hold them all, and then either pass it around or subclass it.

One advantage to having an object to pass around is that it provides an single point that the programmer can go to see what possible variables exist. This is in some respects better than subclassing as you dont have zillions of layers of additional stuff.

My only criticism of you post is that IMO there should not be more than a few parameters to a suboutine. The more parameters a subroutine takes the more difficult it is to understand what it does, and to make mistakes with regard to their position (addmittadly this can be dealt with via named parameters) or omission. Usually this isnt that big a deal, except that it can have a dramatic slowdown on development time and frustration levels.

Yves / DeMerphq
--
Have you registered your Name Space?

  • Comment on Re: Re: Use globals or pass around everything under the sun?

Replies are listed 'Best First'.
Re: Re: Re: Use globals or pass around everything under the sun?
by dragonchild (Archbishop) on Dec 05, 2001 at 18:34 UTC
    Heh. I wasn't going to get into refactoring, though that sounds like what's needed here...

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.