Re: Singleton



I wouldn't implement it that way but it is possible:

interface

type
ESingletonCreate = class(Exception)
end;

Singleton = class
private
class var FSomeData: TStrings;
public
class property SomeData: TStrings read FSomeData;
constructor Create;
end;

implementation

By the by, do you have any objection to the main part of my original
suggestion, which was to define an interface for the singleton and so
hide the singleton class wholesale in the implementation section of the
unit?
.



Relevant Pages

  • Re: Singleton
    ... class var FSomeData: TStrings; ... class property SomeData: TStrings read FSomeData; ... constructor Singleton.Create; ... RAISE ESingletonCreate.Create('This is a singleton class and should never be instantiated'); ...
    (borland.public.delphi.non-technical)
  • Re: Singleton
    ... hide the singleton class wholesale in the implementation section of the ... The interface is of course easily replaced with an abstract class: ... property MyFirstProperty: Integer read GetMyFirstProperty write ... procedure MyFirstProcedure; virtual; abstract; ...
    (borland.public.delphi.non-technical)
  • Re: Windows Service in VB
    ... Your service needs to expose an interface via .Net remoting. ... and register the public class as a well-known singleton. ... You also need to create a WinForms app that can be run by logged-in users. ... if your client app just wants to call methods on the service's remoted ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Singleton & Self := in constructor
    ... > I want to enforce singleton behavior in my TObject derived ... > The basic idea is that clients can call the Constructor any ... But it is much simpler to just use an interface ...
    (borland.public.delphi.language.objectpascal)
  • Re: Singleton
    ... I don't usually go to a string factory or a list factory to ... If you have an abstract DOM interface, for example, and the implementation ... To me it's very clear to go to the DomFactory or singleton ... As mentioned in my posting you unit test a class separate from the ...
    (comp.object)