Popular posts from this blog
C# | Adapter Design Pattern | Structural Design Pattern
Adapter pattern works as a bridge between two incompatible interfaces. This type of design pattern comes under structural pattern as this pattern combines the capability of two independent interfaces. This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop. We are demonstrating use of Adapter pattern via following example in which an audio player device can play mp3 files only and wants to use an advanced audio player capable of playing vlc and mp4 files. Who is what? The classes, interfaces and objects in the above class diagram can be identified as follows: 1. ITraget - Target interface 2. Employee Adapter - Adapter Class 3. ...
C# | Singleton Design Pattern | Creational Design Pattern
Singleton pattern is one of the simplest design patterns in C#. This type of design pattern comes under creational pattern as this pattern provides one of the best ways to create an object. This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class. - The Singleton pattern is a design pattern that restrict the instantiation he lifetime of the application, the instance remains same. - Throughout the lifetime of the application the instance will remain same. - Instance should be requested instead of created, if instance not available then create the instance, then provide otherwise provide available instance. Why we need Singleton design pattern? - When there is single resource throughout the application. e.g- Database, Log File etc. - When there is a single resource and the...
Comments
Post a Comment