I called it FactoryFactory, because
a) from outside it is a factory, in that concern you could also call it the/an abstract Factory.
b) all it really generates is oFactory, the real/normal/concrete factory.
I'm not thinking of THIS_Acess() to create a concrete Factory for every call, but that might even be an option, if oFactory is destroyed again after it has generated the object. Then I'd not do it with THIS_Access() but a normal method generating a factory, calling it then destroying it and passing back the returned object, which might be done in a chain of responsibility.
Concerning empty objects the caller should give some "instructions", what properties he wants. I like to use such objects based on empty as parameter or result objects passed in or out to/from functions/methods. I once posted the following CreateParameterOject Function, which could be some private method of a factory that could lookup the parameters with a class name/token from a factory table:
Local lo
? CreateParameterObject()
lo = CreateParameterObject("iX;iY")
? lo.iX, lo.iY
lo = CreateParameterObject("iX;iY","I;I")
? lo.iX, lo.iY
lo = CreateParameterObject("iX;iY","I;I","20;100")
? lo.iX, lo.iY
lo = CreateParameterObject("cFirstname;cLastname;dBirthdate","C;C;D","Olaf;Doschke;{^1968-12-28}")
? lo.cFirstname, lo.cLastname, lo.dBirthdate
lo = CreateParameterObject("iMembers;cType","I;E","AMembers(laDummy,loObject);Type('loObject.cType')")
? lo.iMembers, lo.cType
Function CreateParameterObject()
Lparameters tcProperties, tcTypes, tcValues
Local loObject
loObject = Createobject("empty")
Local lnCount, lnCounter
Local Array laProperties[1], laTypes[1], laValues[1]
Do Case
Case Pcount() = 0
Case Pcount() = 1
For lnCount = 1 To Alines(laProperties,tcProperties,2,";")
AddProperty(loObject,laProperties[lnCount])
Endfor
Case Pcount() = 2
lnCounter = Alines(laProperties,tcProperties,2,";")
If Alines(laTypes,tcTypes,0,";") # lnCounter
loObject =.Null.
Else
For lnCount = 1 To lnCounter
lcType = laTypes[lnCount]
AddProperty(loObject;
,laProperties[lnCount];
,Icase(lcType="C","";
,lcType="I",0;
,lcType="N",0.0;
,lcType="D",{};
,lcType="Y",$0.0;
,lcType="L",.F.;
,lcType="T",{..::};
,.Null.;
);
)
Endfor
Endif
Case Pcount() = 3
lnCounter = Alines(laProperties,tcProperties,2,";")
If Alines(laTypes ,tcTypes ,0,";") # lnCounter Or;
ALines(laValues,tcValues,0,";") # lnCounter
loObject =.Null.
Else
For lnCount = 1 To lnCounter
lcType = laTypes[lnCount]
lcValue = laValues[lnCount]
AddProperty(loObject;
,laProperties[lnCount];
,Iif(lcType="C",lcValue,Evaluate(lcValue));
)
Endfor
Endif
Endcase
Return loObject
Endfunc
Bye, Olaf.