On 16-Apr-07, at 11:52 AM, Dennis Birch wrote:

> On 4/16/07, Norman Palardy <[EMAIL PROTECTED]> wrote:
>>
>> On 16-Apr-07, at 11:38 AM, Dennis Birch wrote:
>>
>>> On 4/16/07, Charles Yeomans <[EMAIL PROTECTED]> wrote:
>>>>
>>>> On Apr 16, 2007, at 12:26 PM, Dennis Birch wrote:
>>>>
>>>>> Is it possible to not return an instance of a class from its
>>>>> constructor?
>>>
>>>> Not exactly.   If you want to return nil if the constructor fails,
>>>> then you can define a shared method NewSomeClass(rs as  
>>>> RecordSet) as
>>>> SomeClass and call it.
>>>
>>> Thanks Charles. I'm a little confused about this approach. Can you
>>> elaborate?
>>
>> You don't use the constructor directly.
>> You use a shared method that returns an instance of your class.
>> It becomes a factory (something that makes instances of the class)
>
> Thanks Norman. In other words, you're talking about creating a
> fallback that builds an instance of my class with default values?

Not really.
Instead of calling the Constructor (make that private) you HAVE to  
call the "factory" method
It just so happens that the factory method is a shared method IN the  
class.
The nice thing about these kind of methods is you do not have to have  
an instance of the class to call them.

And, if you want you CAN return NIL from them (something you cannot  
do from a Constructor)

It ends up working a lot like a constructor, but it's not a constructor
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to