Static Class:-
You cannot create the instance of static class.
Loaded automatically by the .NET Framework common language runtime (CLR) when the program or namespace containing the class is loaded.
Static Class cannot have constructor.
We cannot pass the static class to method.
We cannot inherit Static class to another Static class in C#.
A class having all static methods.
Better performance (static methods are bonded on compile time)
Singleton:-
You can create one instance of the object and reuse it.
Singleton instance is created for the first time when the user requested.
Singleton class can have constructor.
You can create the object of singleton class and pass it to method.
Singleton class does not say any restriction of Inheritance.
We can dispose the objects of a singleton class but not of static class.
Methods can be overridden.
Can be lazy loaded when need (static classes are always loaded).
We can implement interface(static class can not implement interface).
- Singleton
- Factory Method
- Abstract Factory
- Adaptor
- Façade (Faas Saad)
- Proxy
- Chain of responsibility
- Observer
- Iterator
- A class of which only a single instance can exist.
- Lets you ensure that a class has only one instance, while providing a global access point to this instance.
- Creates an instance of several derived classes.
- Provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created
- Creates an instance of several families of classes
- Create instances of several classes belonging to different families
- Lets you produce families of related objects without specifying their concrete classes.
- Match interfaces of different classes
- Allows objects with incompatible interfaces to collaborate.
- A single class that represents an entire subsystem
- A single class that represents an entire complex system
- Provides a simplified interface to a library, a framework, or any other complex set of classes
- An object representing another object.
- Provides a surrogate object, which references to other object.
- Lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.
- A way of passing a request between a chain of objects
- Passes a request among a list or chain of objects.]
- Lets you pass requests along a chain of handlers. Upon receiving a request, each handler decides either to process the request or to pass it to the next handler in the chain.
- A way of notifying change to a number of classes.
- Allows an object (subject) to publish changes to its state and other objects (observer) that depend upon that object are automatically notified of any changes to the subject's state
- Lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they're observing.
- Sequentially access the elements of a collection
- Provides a way to access the elements of a collection object in sequential manner without knowing its underlying structure.
- Lets you traverse elements of a collection without exposing its underlying representation (list, stack, tree, etc.).
No comments:
Post a Comment