Name of the blog

Short description of the blog

Observer Pattern in ASP.NET

What is Observer Pattern ?

  • Observer Pattern is a Behavioural Pattern which allows one-to-many dependencies between objects so that when one object state changes, all dependent objects can be notified and updated automatically.
  • The Observer Pattern is used to implement communication between objects. Since the state of an object (we'll call it subject) is constantly changing, the Observer pattern allows us to define a one to many dependency between other objects (we'll call them observers) to communicate with them letting all the observers know that a subject has changed its state.
  • This allows us to notify all observers with a single mechanism.
  • The Observer Pattern is set up in the publisher/subscriber pattern, and is excellent for implementing distributed event handling systems and such. This pattern also goes a long way towards removing the coupling between the subject & observer with the use of the IObserver interface.
  • The observer design pattern defines a one to many dependency between an object and its dependents. The dependency is created in order to inform the dependents that the object changed its state and therefore the dependents can react to the change.
  • A very good example of such behavior is the blogging systems were subscribers are notified whenever a blogger published a new post.

http://www.c-sharpcorner.com/uploadfile/shinuraj587/observer-pattern-in-C-Sharp/

http://dotnet.dzone.com/articles/design-patterns-c-observer

http://msdn.microsoft.com/en-us/library/Ee817669(pandp.10).aspx

http://www.codeproject.com/Articles/42255/Observer-Pattern-in-ASP-NET

http://wiki.asp.net/page.aspx/490/observer-pattern/

http://msdn.microsoft.com/en-us/library/ms998543.aspx

http://msdn.microsoft.com/en-us/library/ee850490.aspx

What is difference between Abstraction and Encapsulation

Abstraction 

Abstraction allows us to represent complex real world in simplest manner. It is process of identifying the relevant qualities and behaviors an object should possess, in other word represent the necessary feature without representing the back ground details. Abstraction is a process of hiding work style of an object and showing only those information which are required to understand the object. Abstraction means putting all the variables and methods in a class which are necessary.

Encapsulation

It is a process of hiding all the internal details of an object from the outside real world. The word Encapsulation, like Enclosing into the capsule. It restrict client from seeing its internal view where behavior of the abstraction is implemented. In Encapsulation, generally to hide data making it private and expose public property to access those data from outer world. Encapsulation is a method for protecting data from unwanted access or alteration. Encapsulation is the mechanism by which Abstraction is implemented.

Difference between Abstraction and Encapsulation

Abstraction is a process. It is the act of identifying the relevant qualities and behaviors an object should possess. Encapsulation is the mechanism by which the abstraction is implemented.

Abstraction  Encapsulation
Abstraction solves the problem in the design level. Encapsulation solves the problem in the implementation level.
Abstraction is used for hiding the unwanted data and giving only relevant data. Encapsulation is hiding the code and data into a single unit to protect the data from outer world.
Abstraction is set focus on the object instead of how it does it. Encapsulation means hiding the internal details or mechanics of how an object does something.
Abstraction is outer layout in terms of design. 
For Example: - Outer Look of a iPhone, like it has a display screen.
Encapsulation is inner layout in terms of implementation.
For Example: - Inner Implementation detail of a iPhone, how Display Screen are connect with each other using circuits

What is difference between abstract class and an interface

Feature

Interface

Abstract class

Multiple inheritance

A class may inherit several interfaces.

A class may inherit only one abstract class.

Default implementation

An interface cannot provide any code, just the signature.

An abstract class can provide complete, default code and/or just the details that have to be overridden.

Access Modfiers An interface cannot have access modifiers for the subs, functions, properties etc everything is assumed as public An abstract class can contain access modifiers for the subs, functions, properties

Core VS Peripheral

Interfaces are used to define the peripheral abilities of a class. In other words both Human and Vehicle can inherit from a IMovable interface.

An abstract class defines the core identity of a class and there it is used for objects of the same type.

Homogeneity

If various implementations only share method signatures then it is better to use Interfaces.

If various implementations are of the same kind and use common behaviour or status then abstract class is better to use.

Speed

Requires more time to find the actual method in the corresponding classes.

Fast

Adding functionality (Versioning)

If we add a new method to an Interface then we have to track down all the implementations of the interface and define implementation for the new method.

If we add a new method to an abstract class then we have the option of providing default implementation and therefore all the existing code might work properly.

Fields and Constants No fields can be defined in interfaces An abstract class can have fields and constrants defined

Cheap MLB Jerseys maillot de foot pas cher www.fotballdrakter.org