Environment versions
Network:
Windows 2003 Server
>There is an actual thread in this forum which deals with the concept of using parameters and arrays. Years ago, when using Visual FoxPro, this topic was brought and many recommended to use an array as a parameter instead of passing multiple parameters. Even with a totally OOP environment, sometimes there could be a need to pass multiple parameters. As for me, since the last year, I practically changed everything in regards that to avoid passing any parameter. Basically, all methods return True or Fase, for the success of the method, and all required parameters are then replaced by class properties. I would like to collect feedback on this topic as well as related issues.
Hi Michael,
My opinion here...
VisualFoxPro does not support parameter overloads for the same procedure/function. This might be a reason to use parameter as array or set of parameters as object properties. VS free in this, and support overloading.
Second, I am not sure you way with set properties of object before call the method is a good way. I explain why.
Because in this case you don't know exact order of set value to the properties, and its increase overhead in programming.
First reason - external developer can forgot to set the property value, then method will FAIL in RUNTIME.. but in case with parameters - all problem fixed on DESIGN TIME. This is important!
Second reason - When programmer writing the code - he can see method overloads, types, and OPTIONAL parameters. Of course you can initialize your control with default property values, but on my private look, when I am programming, I'd like to see what I send to the method..
Third reason - When code is MY and I develop it 2 weeks ago - no probelm. I happy, I know and remember all. When another programmer must use your classes - he need more time to look in the help file - which properties should he setup, and maybe.. in which order.
Next.
When you send object as parameter - you always can have a callback. Because objects sends by reference, and you can change the object properties inide your method.. and in calling function - you will have a fresh value .. maybe error code.. maybe errorstring..
In case when you setup properties and method return true/false. I must check the object State.
Next.
Whats about Static functions? Whats about factoryMethods? when object have a private constructor and Shared Function to create it.
So. My voice for parameters!
And main reason - I want to fix most my problems in DESIGN TIME. not in runtime when I call the method, and forgot to setup some properties.
Denis
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only