Singleton Design Pattern explained in Hindi (हिंदी) with code example C# | Design Patterns Series

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024
  • In this video, we will discuss about the singleton design pattern. What is the problem it solves, the code structure of the pattern and code example of using this pattern.
    Recommended readings:
    Clean Architecture: A Craftsman's Guide to Software Structure and Design : amzn.to/3VLJaXc
    Design Patterns: Elements of Reusable Object-Oriented Software: amzn.to/3B4zr4P
    Head First Design Patterns: amzn.to/3B4ZTLJ
    Singleton is a creational design pattern, which ensures that only one object of its kind exists and provides a single point of access to it for any other code.
    Topics covered:
    Introduction to Singleton design pattern
    Problem statement
    Solution provided
    Code Structure
    C# Code example
    Lazy implementation
    Double checked locking
    #designpatterns #cleancode
    ---------------------------------------------------------------------------------------------
    My setup:
    Mic: amzn.to/44HGe1H
    Laptop: amzn.to/3pclzTe
    Keyboard: amzn.to/3B3e3Nn
    Mouse: amzn.to/3VLKB82

ความคิดเห็น • 25

  • @cricomedy7896
    @cricomedy7896 หลายเดือนก่อน +1

    GreaT explaination

  • @varunbhalla4901
    @varunbhalla4901 8 หลายเดือนก่อน +1

    Nice and clear concept explanation thanks

  • @zeeluck7128
    @zeeluck7128 10 หลายเดือนก่อน +1

    Excellent

  • @Pr3kashSingh
    @Pr3kashSingh 11 วันที่ผ่านมา +1

    Thanks

  • @deepalikhairnar4240
    @deepalikhairnar4240 ปีที่แล้ว +1

    It's showing error when I apply lock

    • @CodewithRSV
      @CodewithRSV  ปีที่แล้ว

      What is the error message?

  • @aliasadhassan
    @aliasadhassan 8 หลายเดือนก่อน +1

    Mostly interviews asked this ...on how you can make single pattern thread safe !!! BTW very nice ...God bless you

  • @PratikChilkewar
    @PratikChilkewar 2 หลายเดือนก่อน +1

    very nice explain
    Thank you.

  • @ansarahmad1072
    @ansarahmad1072 ปีที่แล้ว +1

    Great Explanation You have solved my Headache

  • @manishgarg8371
    @manishgarg8371 8 หลายเดือนก่อน +1

    Great explanation, Do you have video on Factory Patter as well ?

    • @CodewithRSV
      @CodewithRSV  8 หลายเดือนก่อน

      th-cam.com/video/I2DbKwKHeUA/w-d-xo.html

  • @abdulkadir-jh2yj
    @abdulkadir-jh2yj ปีที่แล้ว +1

    Thank you so much for making video on pattern could you pls make on all patterns

    • @CodewithRSV
      @CodewithRSV  ปีที่แล้ว

      th-cam.com/play/PLmzGdRRZtjPfkKJroG4fHSKquN5AIpHw3.html

  • @syedmubeenhussain6317
    @syedmubeenhussain6317 2 หลายเดือนก่อน +1

    nice

  • @MrRana1478
    @MrRana1478 ปีที่แล้ว +1

    thanks Sir, Very well explained

  • @dipikabhagat5252
    @dipikabhagat5252 ปีที่แล้ว +1

    Thanks for the great explanation Sir !! . However, I have a question on lock mechanism . Suppose there are two threads trying to create singleton instance then how is the lock deciding which thread should go first?

    • @CodewithRSV
      @CodewithRSV  ปีที่แล้ว +1

      It is a very rare condition for 2 threads to try to acquire a lock at exactly same time but in that case there can be internal thread priorities which can be used. In any case, lock will prevent the threads to execute the code at same time.

    • @dipikabhagat5252
      @dipikabhagat5252 ปีที่แล้ว +1

      Thanks for the reply sir 👍

  • @shagunagrawal3773
    @shagunagrawal3773 ปีที่แล้ว +1

    Great knowledge i appreciate you 🤗

  • @AmmaarNaveed-s5l
    @AmmaarNaveed-s5l ปีที่แล้ว +1

    Very comprehensively described !

  • @RhymePlayKids
    @RhymePlayKids 8 หลายเดือนก่อน +1

    Dose it require to make class as Sealed?

    • @CodewithRSV
      @CodewithRSV  8 หลายเดือนก่อน +1

      It's not mandatory but if you don't make it sealed then someone can create a child class and create multiple objects of the child class. Sealed class will prevent the inheritance.

  • @swapnilsonawane2525
    @swapnilsonawane2525 ปีที่แล้ว +1

    Is it the same way we create singleton class ?

    • @CodewithRSV
      @CodewithRSV  ปีที่แล้ว

      Yes, using singleton pattern and creating a Singleton class is same thing.

  • @pratikburade5221
    @pratikburade5221 ปีที่แล้ว

    Can you made tutorial on blazor with entity framework