Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convoluted intellisense questions
Message
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01348352
Message ID:
01348355
Views:
14
I believe there is a trick to achieve this and once I even had it, but don't recall at the moment. However, there were threads here on this topic before. I did achieve this in FoxUnit.

>I'm probably overthinking this, but I have a question about getting intellisense to work within my project. I support integration with 3 different products for credit card payment services. Right now, the code is very messy to work through these, and I am refactoring. My goal is to create a single payment interface class that works behind the scenes to create the right object and allow transactions to be processed.
>
>I have created a base class for a transaction. It includes properties for all of the information and empty methods for all the different transaction types.
>
>I have created 3 classes based on the base class which include the actual processing methodologies for each different integration.
>
>I have created a master transaction class that includes a property (initialized to null) for a transaction object. The Init() looks at the system configuration, determines the appropriate integration method, and then creates the appropriate object from the 3 integration classes.
>
>Once the master class is instantiated, I can assign the various transaction properties and call the transaction methods from my application without having to worry about what integration methods are selected.
>
>My question is: Is there a way to do this so that I can have intellisense active on the transaction property. Because it is initialized as null, it has no properties. I could create it doing an ADD OBJECT O AS BASECLASS, but then I cannot reassign it to one of the 3 integration class in my init.
>
>If it helps, I have a set of sample programs illustrating the concept.
>testbase.prg defines the base class
>testclass1.prg subclasses testbase and represents the first method performing a task
>testclass2.prg subclasses testbase and represents the second method for performing a task
>testmaster.prg defines a class I can call to perform my task. In the init it determines which method to use and creates an appropriate instance of testclass1 or testclass2.
>testcode.prg contains code that I use to execute task.
>
>The object is to be able to type "o.oTestObject." in testcode and have intellisense for that objects properties and methods.
>
>testbase.prg:
>
>DEFINE CLASS TestBase as Custom
>  testVar1 = ""
>
>  FUNCTION DisplayTestVar
>  ENDFUNC 
>ENDDEFINE
>
>
>
>testclass1.prg:
>
>DEFINE CLASS TestClass1 as TestBase OF TestBase.prg
>  FUNCTION DisplayTestVar
>    WAIT WINDOW this.testVar1
>  ENDFUNC
>ENDDEFINE
>
>
>testclass2.prg:
>
>DEFINE CLASS TestClass2 as TestBase OF TestBase.prg
>  FUNCTION DisplayTestVar
>    MESSAGEBOX(this.testVar1)
>  ENDFUNC
>ENDDEFINE
>
>
>testmaster.prg:
>
>DEFINE CLASS TestMaster as Custom
>
> #if (.f.)
>   LOCAL this as TestMaster OF TestMaster.prg
> #endif
>
>   oTestObject = null
> 
>   PROTECTED nMethod 
>   nMethod = 0
>   
>   FUNCTION Init
>   
>*
>* figure out which method to use - for the sake of demonstration I will hard code a selection
>*     
>    this.nMethod = 2
>    
>    DO CASE 
>      CASE (this.nMethod = 1)
>        this.oTestObject = NEWOBJECT("testclass1", "testclass1.prg")
>        
>      CASE (this.nMethod = 2)
>        this.oTestObject = NEWOBJECT("testclass2", "testclass2.prg")
>        
>    ENDCASE
>    
>  ENDDEFINE
>
>
>
>testcode.prg:
>
>LOCAL o as TestMaster OF TestMaster.prg
>
>o = NEWOBJECT("testmaster", "testmaster.prg")
>o.oTestObject.testVar1 = "Hello World"
>o.oTestObject.DisplayTestVar()
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform