Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OO Design Question and recursion question?
Message
From
21/09/1999 17:38:21
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00266441
Message ID:
00267351
Views:
24
>>Derek,
>>
>>>Can I actually have recursive objects or just function calls?
>>
>>The recurrsion limit applies to the total nesting of function and method calls.
>>
>Lets say I have an object called Part that has a link to another object called Subassembly.
>Subassembly contains an object collection. It has a method called loopThruCosts() that will go thru the collection and will call the calculateCost() method of all the objects in its collection. The collection can contain an ObjectID for another Part object.
>Now Part has a method called calculateCost() that first checks for a link to Subassembly, and if so then calls the Subassembly.loopThruCosts() and so on.
>Now my question is with this scenereo, does VFP6 consider this recursion?

Derek,

My bet is that you'd have to work *REAL* hard to get to 128 levels of recursion so I'd say, yes, FoxPro can handle what you're wanting *if that's the best way to go*. I emphasize that last part just to make sure you get "nudged" to take a look at your design to make sure that a recursive solution is what you need.

Remember, if you're recursive routine is correctly constructed you would have to have a component list 127 levels deep. It would surprise me if you got past 3-4. The problem most people have is a nesting problem, not a recursion problem. The recursive routine will always back up to the highest unfinished 'level'. I kind of think of them like maze rats; they always "walk" the outside edge. *g*

I've never tried to use a recursive -object- but I don't see why it wouldn't work.

For some stuff recursion is the only way to go IMO.

Best,
Best,


DD

A man is no fool who gives up that which he cannot keep for that which he cannot lose.
Everything I don't understand must be easy!
The difficulty of any task is measured by the capacity of the agent performing the work.
Previous
Reply
Map
View

Click here to load this message in the networking platform