Skip to content

Is there a reason why Config class does not implement the Singleton pattern? #22

@jnareb

Description

@jnareb

Is there a reason why Config class does not implement the Singleton pattern? Or use other equivalent pattern (Monostate, Factory, or Dependency Injection)?


Additionally, each of the classes in the `trackers/' subdirectory behaves differently with respect to implementing the Singleton pattern.

The ScreenRecorder class implements the Singleton pattern, with getInstance() static method, which is not thread safe implementation

    public static ScreenRecorder getInstance() {
        if (instance == null) {
            instance = new ScreenRecorder();
        }
        return instance;
    }

The IDETracker class implements the getInstance() static method, but not the Singleton pattern:

    public static IDETracker getInstance() throws ParserConfigurationException {
        return new IDETracker();
    }

The EyeTracker class does not implement the getInstance() static method.


For AnAction classes, the getInstance() method it is often implemented by JetBrains as, for example:

  private static final String ID = "<Plugin>.<Action Name>";

  // ...

  public static @Nullable AnAction getInstance() {
    return ActionManager.getInstance().getAction(ID);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions