I am working on a class in VBA that encapsulates file loading using MSXML2.XmlHttp.
There are three possibilities for the return value: text, XML, and stream.
Should I create a function for each of them:
aText=myDownloader.TextSynchronous(URL,formData,dlPost,....)
aXml.load myDownloader.XmlSynchronous(URL,formData,dlPost,....)
Or I can just return the XmlHttpObject created inside the class and then
aText=myDownloader.Synchronous(URL,formData,dlPost,.....).ResponseText
aXML=myDownloader.Synchronous(URL,formData,dlPost,.....).ResponseXML
In the first case, I can set obj to nothing in the class, but I must write several functions that are more or less the same.
In the latter case, I pass in the "garbage collector", but has a more compact class.
Both should work, but which coding style is better?
source
share