Saturday, August 14, 2021

Singleton design pattern

The singleton pattern is one of the best-known patterns in software engineering. Essentially, a singleton is a class which only allows a single instance of itself to be created, and usually gives simple access to that instance. Most commonly, singletons don't allow any parameters to be specified when creating the instance

public sealed class Singleton

    {

        private Singleton _object;

        private Singleton() {}


        public Singleton GetInstance

        {

            get

            {

                if(_object == null)

                {

                    _object = new Singleton();

                }

                return _object;

            }

        }

    }

No comments:

Post a Comment

Find the value from array when age is more than 30

 const data = [   { id: 1, name: 'Alice', age: 25 },   { id: 2, name: 'Bob', age: 30 },   { id: 3, name: 'Charlie', ...