Difference between an Abstract class and an Interface.

There are technical differences between Abstract Classes and Interfaces, that being an Abstract Class can contain implementation of methods, fields, constructors, etc, while an Interface only contains method and property prototypes.

Two quick thoughts on differences between interfaces and abstract classes:

  1. Abstract classes desired if future expansion is likely, as an abstract class can be expanded, but an interface would have to be enhanced by addition of another interface, I2.

2. A class can inherit multiple interfaces but only one abstract class.

An Interface defines what something can do (how it behaves), and an Abstract Class defines what something is. Continue reading

Detention Time Calculator.

Johnny has been a bad boy. He has committed several offenses and played a lot of pranks at school. He has been caught and now Mr. Wilson, the school head master has to give him detention. The period of detention depends on several factors as per rules of the school board and poor Mr. Wilson needs some help. Continue reading

Abstract Class Vs Interface

An abstract class is a special kind of class that has no implementation. It cannot be instantiated. Its implementation logic is provided by the classes that derive from it. It can have both abstract as well as non-abstract methods.
It is not compulsory to have only abstract methods in an abstract class. We can also have an abstract class with only non-abstract methods.

Why do we need an Abstract Class? Continue reading

What is Dependencyproperty and Dependency object

Dependency property can be linked to another property such that a change in the value of one changes the other.

The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs. These other inputs might include system properties such as themes and user preference, just-in-time property determination mechanisms such as data binding and animations/storyboards, multiple-use templates such as resources and styles, or values known through parent-child relationships with other elements in the element tree.

CLR property vs Dependency property: Continue reading

Facade Design Pattern.

Where to use?

   When there are some sub tasks or series of subsystems.

In such cases we need to bother about all the subsystems or we can say we need to remember all the classes, methods and sequence of calling. So to avoid this situation, we can use Facade pattern which provides an interface to client code and hide all the subsystems.

Lets takes an example for facade design pattern. Suppose I need to turn off my Desktop. So the activities involve in this task is : 1. Save my Work and ShutDown Windows. 2. Turn off Monitor 3. Turn off UPS. So there are 3 subsystems and my program looks like: There are 3 different classes with their respective methods. Continue reading