Re: OOP style



"swansnow" <schultz@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1125001669.617678.171510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

> Nested routines... Do you mean you declare procedures inside a
> procedure? That sounds intriguing.

That's Pascal for you.

There are drawbacks, though. In some of the more interesting cases,
they can't be used.


> In my scenario of a humongous method, needing to be broken down, then,
> would you put the "helper" methods nested inside the "main" method?

Sometimes. It limits code reuse, though, so unless the oversized method
very naturally falls to pieces, there is not all that much call to do
this.

But sometimes the outer method congeals into five simple procedure calls.
That does look nice.


> Scope-wise, does this mean that the nested procedures are only visible
> to the containing procedure? Do they have access to the class's
> variables, and the containing procedure's variables, too?

Yes, yes, and yes.

The last yes is provisional. They have access to local variables in
the containing routine that were declared _before_ the nested routine.
Since this is entirely too much like global variables, I consider
this reason enough to declare all local variables _after_ any nested
routines, and pass parameters if they are needed.

It probably has access to the outer procedure's parameters, though,
and this can't be fixed. But it can be ignored.

Groetjes,
Maarten Wiltink


.



Relevant Pages

  • Re: Public Variables
    ... If you wanted to really follow the OOP paradigm, ... > Are you stating that I should ALWAYS declare ALL variables as private? ... > My object is not to learn programming style as I only wrote this one ... >>> The program consists of 2 forms, and about 12 routines I wrote. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Public Variables
    ... Are you stating that I should ALWAYS declare ALL variables as private? ... when every other proceedure needs to know the new value. ... >> The program consists of 2 forms, and about 12 routines I wrote. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Will undefined varialbes test as False?
    ... This is a situation were I can't declare the variable or not easily. ... These are debug routines that test a global switch ... call them from the immediate window, unless it is after a break, those ... If the routine is called from the program, the switch will have ...
    (microsoft.public.vb.general.discussion)
  • Re: reusing routines
    ... > delare it in my uses clause I should be able to address those routines ... one at the start of the interface section and one at the implementation ... If both Main and Library declare a type TIndex, ... stricter, visibility rules. ...
    (alt.comp.lang.borland-delphi)
  • Re: Unsigned Integer
    ... > What do you declare ix% an iy% as? ... The trailing "%" on the variable name declares it as Integer (from BASIC ... set of routines on some of the VB code sites. ...
    (microsoft.public.vb.syntax)