Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multiple Return Values
Message
From
07/12/2001 08:10:06
 
 
To
07/12/2001 06:35:10
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00590869
Message ID:
00591067
Views:
36
>>Actually, I use parameter object a whole lot in order to simplify interfaces. A method takes a parameter object as input; you can now hold and pass as many complex values as you want in a single parameter, and carry it as a form parameter and have its values and behaviors persist along the life of an object like a form. A method returns a parameter object, which the caller can examine and query for content and more importantly it can carry behavior back to the caller!
>
>Ed, what is this about "carrying behavior"? This is the only part of your message which I didn't quite understand.

The parameter object not only can carry parameters, it can carry methods, which can be invoked by the form receiving the object. These methods can vary in their implementation from parameter object to parameter object; the easiest way to ensure that life is easy is to have a number of concrete classes derived from a common abstract class, and so the parameter object passed back is instantiated from one of these common concrete classes with a commt of propert and methods exposed, but internally behave quite differently.

Let's take an intentionally ridiculous scenario; we have a vehicle rental business object, with a method SelectVehicleType. SelectVehicleType takes a parameter object as input; this parameter object describes the characteristics of the renter's requirements, the types of things hed knows how to do (start car, steer, brake, parallel park), the vehicle's required characteristcs (size of car, max cost/day, availability period, optional features like convertible or A/C), and information about the driver's known driving habits (runs red lights, prefers to run over nuns in crosswalks, has to park the car on the street.) The set of information for each renter is going to vary in the completeness of the property set, some properties may be multivalued, requiring a collection or member array, or might specify the mechanism to use to generate the bills to the customer (tell it to cut 3 separate invoice each for 1/3rd, for example) or discount plans available to the customer.

As an example, I go into the local Rent-A-Clue Car Company, and fill out a brief questionaire on-screen; thye detail captured is placed into a parameter object, passed to SelectVehicleType. They look at my requirements and skills, and decide based on my requirements for off-road capabilities, impatience with traffic jams, and poor driving record that I need a chauffered vehicle that can go off-road, with mechanisms to avoid traffic jam. Based on the time requirements, Rent-A-Clue only has one vehicle type with a driver available, so it creates a parameter object of class TankRental, derived from the abstract class VehicleRental, and add an object of type TankCrew to the VehicleOptions collection of TankRental, and assign properties of StartingMileage, FuelState and the property NumberOfHEATRoundsOnBoard, which is unique to TankRental objects. The class offers the same standard set of methods (Stop, Go, Turn Left, Turn Right) as all other classes drived from VehicleRental, but whose internal behavior is rather different than the behavior associated with say, an AMC Gremlin, to do the same things. In addition, there are some extra methods available to the TankRental object, such as LoadCannon, AimMainGun and Shoot which are made available. The TankRental object is instantiated as noted above and returned from SelectVehicleType. Based on the information that a TankRental object was returned, and that I'm impatient sitting in traffic, the tank crew is issued instructions "Hey, if you hit a traffic obstruction, shoot the car that's creating the problem, and roll right over it!"

From my POV, the normal behaviors of 'Turn Right', 'Turn Left', 'Stop', 'Go' are all there, just like every other vehicle I could pick up at the RAC Vehicle Rental Center. In addition, I can query the PEMs of the returned object to see what unique characteristics are available, and choose to use them or not as like. I don't need to know the details of exactly how the tank's engine and drivetrain work as long as standard public methods which take the same inputs an any other VehicleType-derived concrete class.

IOW, I can specify the details of how to accomplish my goals for future processing through the set of methods returned inside the called-method-returned parameter object, and both the properties and methods persist beyond the scope of the creating method or its parent object!

Does this make sense? And is it clear you don't want to stall out in the intersection if I've rented a tank for the day while my Lincoln is in the shop? < g >
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform