Monday 30 May 2011

Kanban


Kanban is a Japanese word that loosely translated means “signal card.”  Kanban’s underlying thesis is that by using signal cards at various points in the production process to indicate the amount of work completed, you can limit the amount of work in progress (WIP) and thus keep the system very “lean” and agile. Work in Progress (WIP) represents inventory and inventory is expensive to keep.
Kanban was originally developed at Toyota as part of the Lean manufacturing movement to facilitate pull systems in a just in time (JIT) production manufacturing process. Work is pulled through the system in single units by demand, instead of pushed in batches. Think Dell computer’s JIT assembly of your laptop as you order it; Dell is pulling a single unit through its production process on demand as opposed to pushing through a batch of computers and selling them pre-configured.
What is Best, Scrum or Kanban?
I have been thinking from some time now that what is best, Kanban or Scrum?. I can't make up my mind so I decided to write an article in two parts, one where I wear the "I love Kanban" hat and one where I'm wearing an "I love Scrum" T-shirt.


SCRUM
Scrum is about getting back to the time when the company was small, everything seems easy and run smoothly. Back then projects were small, teams were small, releases were small and communication was easy. Best of all, we were efficient.

In Scrum we split our big project into small projects as we work on time boxed iterations called sprints. We split our big team into small teams (still with all the skills we need) and launch often. If we are more than 20 employees we probably have a problem knowing what the other departments and customers are needing so let's bring someone into the team that can represent them. To help communications from the team to the rest of the company we have our plan and current status visible. The plan is called the sprint backlog and the status is shown on the scrum board. Here is an example:

The person we brought in to represent all stakeholders is called product owner and is responsible for prioritizing a list with features that will be developed for the product in the future. This list is called the product backlog.
To make Scrum a process we add some small but necessary meetings: a planning meeting, daily synchronizing meeting and meetings to improve product and process.  We decide the length of our iterations and aim to deliver something valuable after each iteration.


KANBAN
Scrum is simple but Kanban is even simpler. Just visualizing your workflow and limiting demand to capacity is enough to call it Kanban.

Let's start by looking at the roots of Kanban. It's a way, invented and used by Toyota, to get a good flow of parts to their plants. Kanban is just a card attached to the part and when the part is used the Kanban is sent as a request to the supplier for more parts. The physical card is actually sent to the supplier who is attaching it to the next pert sent. Since the cards are re-used and no new cards are entered in the circulation, Toyota limits the number of parts in stock and at the same time makes sure new parts are ordered as soon as they are needed.
In software development Kanban is a limited promise of work. A Kanban board is a number of placeholders for work to be done. A typical Kanban board can look like this. 
Each team has decided their limit and drawn as many squares as the limit allows them to. Whenever a task is done it will be moved to the next group if and only if they have free Kanban squares. Else the task is stuck. If there is nothing more to do we have a problem with the flow and we need to work together to solve what is stopping us.
While Scrum is focusing on delivering on commitment Kanban is focusing on getting a smooth flow.

In common for Scrum and Kanban
There are a lot of similarities between Scum and Kanban. Some examples are:
  • A strict prioritization (it's obvious what to do next)
  • Self-organizing teams (see below)
  • Transparency (show what you've done, your current status and what's next to do)
  • Inspect & adapt (improve your product and process based on facts)
  • Pull scheduling (see below)
  • Good communication and collaboration
Self-organizing teams is when the team themselves are supposed to figure out how to solve problems, remove impediments and optimize their process. They should base their decisions on facts to inspect and adapt accordingly.
Pull scheduling means the team is pulling work instead of having it pushed. This will limit work to capacity and lower stress, which is bad for both health and quality.

This is why I prefer Scrum
So, now that you know what Kanban and Scrum is, it's time to decide which is best. 

I start by putting the Scrum T-shirt on. Look further down if you like to read the part where I love Kanban.
I concentrate on some areas where Scrum and Kanban differ:
  • Iterations - In Scrum you work in iterations. Kanban sees development as a forever ongoing flow of things to do.
  • Commitment - In Scrum a team commits to what they will do during a sprint.
  • Estimations - In Scrum you need to estimate to be able to have a velocity. In Kanban it's optional since focus is on time-to-market.
  • Cross-functional teams - That's one of the pillars of Scrum. For Kanban it's optional.
Efficiency driven by commitment
By asking a team for a commitment they will get a positive stress knowing that people from outside will see if they can do what they committed to. It also gives an energy boost at the end of the sprint when the team has the goal within reachable distance. After the sprint, the team can feel relaxed and gather some new energy for the next sprint. It's psychologically nice to not feel you are in the middle of a never-ending stream of things to do. Instead Scrum concentrates on one sprint at a time and allows you to focus only on those things you have decided to take on in the sprint. By working in fixed length iteration you get a nice rhythm the whole company can feel and adapt to.

The value of estimating

Estimating is not a waste of time since valuable information is transferred from the product owner while the team asks what they need to know to be able to estimate. The same thing applies to commitment. To be able to commit team members need to know what they are committing to. They simply have more interest in getting information from the product owner so they listen more carefully. And they are just asking for the information they need which makes the meeting very efficient.

Even though you can predict when a project is done, just by counting stories left, it is more precise if each story is estimated as well. Prediction is important when more departments, like marketing, are dependent on your work. It gives a more serious feeling.

Slack at end of sprints
If there are some time at the end of a sprint that's valuable even if the time is not big enough to start developing new features. This is time developers can use to improve code quality or the development environment. Both will give better efficiency in the long run.

Build teams with cross-functionality

Working together in a cross-functional team is a psychological thing. You are able to go the whole way from concept to released product together as a team without dependencies. You are not just a cog in the machinery. It's also fun and helps you grow as a person. By helping each other, knowledge is spread which lessens dependencies on each person. It also helps prioritize since features can be built without considering which knowledge is available. To coordinate between people with the same skills who are sitting in different teams you can have virtual team meetings as often as needed.

Scrum is best for beginners

I know, you can do all those things even when doing Kanban but they are optional and since they are optional you might just not do them just because you are too lazy to challenge the usual procedures or structures of your company. If you are new to Agile development it's better to have a method guiding you to do the right things. Just read the book and implement it. Later when you get used to it you can start experimenting and eventually get better performance. If you start experimenting too early you might end up with waterfall or chaos but still calling it Agile. Kanban is more advanced because you need to make a lot of decisions without having many facts.

This is why I prefer Kanban
Now it's time to take off the Scrum-T-shirt and put on my "I love Kanban"-hat.

Kanban is based on Lean principles
Kanban is Lean and has been around for 50 years and has shown to be successful. Things are seen as a flow without iterations. Not many rules. It's just a focus on reducing work in progress, strict prioritization and limiting demand after capacity. Besides that you have the normal Lean principles of:
  • Quality
  • Just-in-time (decisions and facts just when they are needed)
  • Short lead-time (quickly from concept to cash),
  • Kaizen (continuous improvement)
  • Minimizing waste (everything that is not adding value to the customer)
No meetings if it's not adding value to the customer. Most of those things are fine with Scrum but I can sometimes think Scrum has some waste. Here I will mention some areas where Scrum practices might be waste.

Estimations might be waste
If a product owner knows what needs to be done and the only goal is to have it done as soon as possible, why spend time on estimating? In Scrum, estimations are needed for a team to know how much to commit, to calculate velocity and for the product owner to decide on prioritization. If none of this is needed, it's waste and we shouldn't do it. If you like to measure velocity you can instead count the number of stories done per week or month. While talking about measurement why not look at something the customers are interested in, lead-time. That is, the time it takes for the customer to get what he or she ordered.

Constant flow

If the team is done with a story and there is not enough time left in the sprint to complete the next, it's likely no one works hard the remaining time and that's waste. Kanban is trying to get a steady and non-stressed but high flow of work running through development.

Sitting with people that can help you
In Scrum a team is cross-functional and sits together with the people working with the same project and not with the ones with the same knowledge. Let's say you work with sound effects for a computer game. Then it's not much help to have a java-programmer beside you. It would be more valuable to sit with people doing the same things as you do who can help you with tools and practices.

No possibility to commit

In Scrum, the team commits which does not work very well for a team with support issues. They get a lot of disturbance and commitment is not worth anything since the ones disturbing them don't care about commitment. A commitment you can't control gives either frustration and stress or demotivation.

Kanban for support and operation teams

Support and operation teams are often interrupted. It's part of their job. Frustration comes when interruptions are happening just because there were no times for pre-emptive work. Just by having the pre-emptive work on the board gives focus to fix the hardest problems one-by-one, which gives less interruptions and more time to work pre-emptively. It becomes a good circle.

A Kanban board for an operation team can look like this:

Most important are the urgent problems that arise. Secondly, daily duties must be done. Then the team members can take care of other projects, usually to improve stability in the operation environment. The limitation on the number of parallel tasks gives focus to be done working on improvements, not just starting them.

Many options gives freedom
Kanban is simple with few constraints, which gives you freedom to change your process step by step. Either you go from waterfall or chaos, your first step is to visualize and limit your flow with a Kanban board. When you have your flow visualized you add whatever work is needed to thrill your customers. Your improvements might be decided during a monthly retrospective meeting or on a daily meeting.

The workflow

A direct consequence of this difference in rules is the way the work items are handled across time.
In Scrum, you select the work you'll be doing for the next sprint beforehand. You then lock the sprint, do all the work, and after a couple of weeks - the usual sprint duration - your queue is empty.
Typical flow of a Scrum process

In Kanban, all that's limited is the size of the queues, called the Work In Progress limit. This means that you can change the items in the queues at any time, and that there's no "sprint end". The work just keeps flowing.
Kanban flow, with a WIP limit of 3 for the Todo, and 2 for the Ongoing.

Design Pattern


Design patterns are recurring solutions to software design problems you find again and again in real-world application development. Patterns are about design and interaction of objects, as well as providing a communication platform concerning elegant, reusable solutions to commonly encountered programming challenges.
The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. They are categorized in three groups: Creational, Structural and Behavioral.
Creational Design Pattern: This design pattern focuses on how object are created and utilised in an application. They tackle the aspects of when and how objects are created, keeping in mind what’s the best way these objects should be created.
Some commonly known Creational Design Patterns are
a.      Abstract Factory Pattern: This pattern is used to create concrete class instances without specifying the exact class type. The Abstract Factory Pattern provides a way to encapsulate a group of individual factories that have a common theme. Abstract Factory Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Example: Let’s take example for developing web and windows application control. We have factory for Button controls having Web Button, Windows Button and we have factory for Textbox control Web Textbox, Windows Textbox.  Now I want to create object for web or windows without specifying there concrete classes. In this situation I will use abstract factory.


namespace DesignPatterns.Creational.AbstractFactory
{
   

    #region " Abstract classes for Common Controls"

    /// <summary>
    ///  abstrct class MyButton
    /// </summary>
    public abstract class MyButton
    {
        //Method to get Button Information.
        public abstract void GetInformation();
    }

    /// <summary>
    ///  Abstract class Textbox.
    /// </summary>
    public abstract class MyTextBox
    {
        //Method to get Textbox Information.
        public abstract void GetInformation();

    }

    #endregion

    #region " To Create the Windows or Web Controls "

    #region " Windows Controls"
   
    /// <summary>
    ///  Windows button Class which inherits MyButton Class
    /// </summary>
    public class WindowsButton : MyButton
    {
        //override the MyButton class method.
        public override void GetInformation()
        {
            Console.WriteLine("Windows Button");
        }
    }

    /// <summary>
    /// windows textbox class which inherits MyTextbox class.
    /// </summary>
    public class WindowsTextBox : MyTextBox
    {
        //override the MyTextbox class method.
        public override void GetInformation()
        {
            Console.WriteLine("Windows TextBox");
        }
    }
   
    #endregion

    #region " Web Controls"

    /// <summary>
    ///  Web button Class which inherits MyButton Class
    /// </summary>
    public class WebButton : MyButton
    {
        //override the MyButton class method.
        public override void GetInformation()
        {
            Console.WriteLine("Web Button");
        }
    }

    /// <summary>
    /// Web textbox class which inherits MyTextbox class.
    /// </summary>
    public class WebTextBox : MyTextBox
    {
        //override the MyTextbox class method.
        public override void GetInformation()
        {
            Console.WriteLine("Web TextBox");
        }
    }

    #endregion

    #endregion

    #region " Control Factory"

    /// <summary>
    ///  Abstract Class  ControlFactory which contain abstract Method to Create Button and Textbox.
    ///  The methods will return the object of MyButton and MyTextbox class.
    /// </summary>
    public abstract class MyControlFactory
    {
        // metod which will return MyButton object.
        public abstract MyButton CreateButton();

        // metod which will return MyTextBox Object
        public abstract MyTextBox CreateTexbox();
    }

    // Concrete Windows Factory Class.
    public class WindowsFactory : MyControlFactory
    {
        public override MyButton CreateButton()
        {
            //object of windowsbutton class    
            return new WindowsButton();
        }
        public override MyTextBox CreateTexbox()
        {
//object of windowstextbox class
            return new WindowsTextBox();
        }
    }
    // Concrete Web Factory Class.
    public class WebFactory : MyControlFactory
    {
        public override MyButton CreateButton()
        {
//object of Webbutton class
            return new WebButton();
        }
        public override MyTextBox CreateTexbox()
        {
//object of webtextbox class
            return new WebTextBox();
        }
    }

    #endregion


    #region " Client Class"

    public class MyApplicationClass
    {
        private MyButton button;
        private MyTextBox textbox;

        /// <summary>
        ///  Constructor of MyApplicationClass
        /// </summary>
        /// <param name="objControlfactory">object of MyControlfactory(Windows or Web)</param>
        public MyApplicationClass(MyControlFactory objControlfactory)
        {
            this.button = objControlfactory.CreateButton();
            this.textbox = objControlfactory.CreateTexbox();
        }

        /// <summary>
        ///  To get the informaiton about the controls.
        /// </summary>
        public void GetInformation()
        {
            this.button.GetInformation();
            this.textbox.GetInformation();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {

            WindowsFactory objWindows = new WindowsFactory();
            MyApplicationClass objapplication = new MyApplicationClass(objWindows);
            objapplication.GetInformation();

            WebFactory objWeb = new WebFactory();
            MyApplicationClass objWebapplication = new MyApplicationClass(objWeb);
            objWebapplication.GetInformation();
        }
    }

    #endregion

}


b.      Builder Pattern:  Separate the construction of a complex object from its representation so that the same construction process can create different representations. This is useful because the same method that deals with construction of the object can be used to construct different design constructs.
Example: Let’s take an example of Construction Company. If a builder wants to build a glass house then the required parts are glass floor, glass walls, glass doors and glass windows. Same way if he wants to build a wooden house then the required parts are wooden floor, wooden walls, wooden door and windows. Now the developer will bring the raw material and make the parts (glass windows or wooden windows) as per his requirements. Once the part development process will completed, the developer will build the house.

namespace DesignPatterns.Creational.Builder
{
    // House Part class
    public class HousePart
    {
        #region " Private Variables"
       
        private string strPartName;
       
        #endregion

        #region " Properties"

        public string PartName
        {
            get
            {
                return this.strPartName;

            }
        }

        #endregion

        #region " Constructor"

        public HousePart(string partname)
        {
            this.strPartName = partname;
        }

        #endregion

    }

    public class House
    {
        #region " Private Variables"
       
        private string strMaterial;
        private List<HousePart> objHousePart;

        #endregion

        #region " Properties"

        public string Material
        {
            get
            {
                return this.strMaterial;
            }
        }

        #endregion

        #region " Constructor"
      
        /// <summary>
        /// construct the new house with given material.
        /// </summary>
        /// <param name="material">House material</param>
        public House(string material)
        {
            this.strMaterial = material;
            this.objHousePart = new List<HousePart>();

        }

        #endregion

        #region " Methods"

        /// <summary>
        ///  To add the parts.
        /// </summary>
        /// <param name="parts">object of house Part.</param>
        public void AddParts(HousePart parts)
        {
            this.objHousePart.Add(parts);
        }

        public override string ToString()
        {
            return string.Format("{0},\n{1}\n{2},\n{3},\n{4}", this.strMaterial, this.objHousePart[0].PartName, this.objHousePart[1].PartName, this.objHousePart[2].PartName, this.objHousePart[3].PartName);
        }
        #endregion

    }

    public abstract class HouseBuilder
    {
        #region " variables"

        // Protected variable - object of house

        protected House objHouse;

        #endregion

        #region " Properties"

        // Protected variable

        public House House
        {
            get
            {
                return this.objHouse;
            }
        }

        #endregion

        #region "Abstract Methods"

        public abstract void BuildDoors();
        public abstract void BuildWindows();
        public abstract void BuildWalls();
        public abstract void BuildFloor();
        public abstract House GetHouse();


        #endregion
    }

    // class inherited form House Builder class.
    public class GlassHouseBuilder: HouseBuilder
    {
        public override void BuildFloor()
        {
            objHouse = new House("GlassHouse");
            House.AddParts(new HousePart("..Stone Floor"));

        }
        public override void BuildWalls()
        {
            House.AddParts(new HousePart(House.Material + "..Walls"));
        }
        public override void BuildWindows()
        {
            House.AddParts(new HousePart(House.Material + "..Windows"));

        }

        public override void BuildDoors()
        {
            House.AddParts(new HousePart("..Wood Door"));

        }
        public override House GetHouse()
        {
            return objHouse;
        }
       
    }

    public class Contractor
    {
        public void  Construct(HouseBuilder housebuilder)
        {
            housebuilder.BuildFloor();
            housebuilder.BuildWalls();
            housebuilder.BuildDoors();
            housebuilder.BuildWindows();

        }

    }
}
class Program
    {
        static void Main(string[] args)
        {
           

            Contractor objContractor = new Contractor();
            GlassHouseBuilder objGlasshouse = new GlassHouseBuilder();
            objContractor.Construct(objGlasshouse);
            House objHouse = objGlasshouse.GetHouse();
            Console.WriteLine(objHouse);


           
        }
}
c.       Factory Pattern: provide interface to create object, but let sub class decide whose object will be created. In other words creating object without exposing the instantiation logic to client.
Example: In real time example bank has many account type like Saving, Current and Fixed accounts. All account type has different type of facilities.

namespace DesignPatterns.Creational.FactoryMethod
{
  

    // Abstract class Fascilites -
    public abstract class Fascilities
    {
        // Method to get the Fascilities
        public abstract void GetData();
    }

    public class ATM : Fascilities
    {

        public override void GetData()
        {
            Console.WriteLine("ATM");
        }
    }
   
    // Cheque class inherits Fascilities class.
    public class Cheque : Fascilities
    {
        public override void GetData()
        {
            Console.WriteLine("Cheque");
        }
    }

    public class Deposit : Fascilities
    {
        public override void GetData()
        {
            Console.WriteLine("Deposited");
        }
    }
   
    public class Interest : Fascilities
    {
        public override void GetData()
        {
            Console.WriteLine("Interest Given");
        }
    }

    // OverDue class inherits Fascilities class.
    public class OverDue : Fascilities
    {
        public override void GetData()
        {
            Console.WriteLine("Overdraft Given");
        }
    }

    public class Widthdrawal : Fascilities
    {
        public override void GetData()
        {
            Console.WriteLine("Widthdrawl");
        }
    }

    // Abstract Class account.
    public abstract class Account
    {

        private List<Fascilities> fascilities = new List<Fascilities>();

        // Property
        public List<Fascilities> AccountFascliites
        {
            get
            {
                return this.fascilities;

            }
        }

        // Constructor

        public Account()
        {
            // call the method get properties.
            GetFacilites();
            DisplayFascilities();
        }

        public abstract void GetFacilites();

        public abstract void DisplayFascilities();



    }

    public class Current : Account
    {
        public override void GetFacilites()
        {
            base.AccountFascliites.Add(new Deposit());
            base.AccountFascliites.Add(new Widthdrawal());
            base.AccountFascliites.Add(new Cheque());
            base.AccountFascliites.Add(new OverDue());
        }
        public override void DisplayFascilities()
        {
            Console.WriteLine(" Current Account Fascilities");
            base.AccountFascliites[0].GetData();
            base.AccountFascliites[1].GetData();
            base.AccountFascliites[2].GetData();
            base.AccountFascliites[3].GetData();

        }
    }

    public class Fixed : Account
    {
        public override void GetFacilites()
        {
            base.AccountFascliites.Add(new Interest());
            base.AccountFascliites.Add(new Deposit());
            base.AccountFascliites.Add(new Widthdrawal());
        }
        public override void DisplayFascilities()
        {
            Console.WriteLine(" Fixed Account Fascilities");
            base.AccountFascliites[0].GetData();
            base.AccountFascliites[1].GetData();
            base.AccountFascliites[2].GetData();

        }
    }

    public class Savings : Account
    {
        public override void GetFacilites()
        {
            base.AccountFascliites.Add(new Interest());
            base.AccountFascliites.Add(new Deposit());
            base.AccountFascliites.Add(new Widthdrawal());
            base.AccountFascliites.Add(new Cheque());
            base.AccountFascliites.Add(new ATM());


        }
        public override void DisplayFascilities()
        {
            Console.WriteLine(" Saving Account Fascilities");
            base.AccountFascliites[0].GetData();
            base.AccountFascliites[1].GetData();
            base.AccountFascliites[2].GetData();
            base.AccountFascliites[3].GetData();
            base.AccountFascliites[4].GetData();
        }
    }

}
class Program
    {
        static void Main(string[] args)
        {
           

            Savings saving = new Savings();
            Console.WriteLine(Environment.NewLine);
            Fixed fiexe = new Fixed();
            Console.WriteLine(Environment.NewLine);
            Current current = new Current();


           
        }
}



d.      Prototype Pattern: prototype design patter is also a pattern we use to receive an object instance for a particular class, such as builder and factory pattern. Instead of having a new fresh object every time, we can make a copy of an existed object instantly (object we can use as Prototype) and start using it. In that way, we do not have to repeat the building process for the object we are trying to use. The new copy object is totally independent with the original prototype object, and can be used for any purpose that will not affect the original. There is no limit for copying the existing objects; any existing object can be copied.
Example: When the builder wants to build a house he will go with the Builder Pattern which makes his work easy. Purchase of raw material, creation of parts and making a house. Next time the developer wants to make the glass house he need to go over the same steps again and again .Finally he was tired of doing this so he asked me is there is any copy mechanism that could help him to make a copy of his developed house any time he wants to have one.
Prototype design pattern could satisfy developers wish. In this case he can make a copy of his developed house (prototype) and decorate it in different way.

namespace DesignPatterns.Creational.Prototype
{
    /// <summary>
    /// Door class is a class that we are going to make cloneable.
    /// In C# .NET, we inherit ICloneable interface to make our class a cloneable class.
    /// In order to implement the clone() method, either shallow copy or deep copy could be used.
    /// </summary>
    public class Door:ICloneable
    {
        public string DoorColor
        {
            get;
            set;

        }
        public int DoorSize
        {
            get;
            set;
        }
        public string DoorType
        {
            get;
            set;
        }

        public void Display()
        {
            Console.WriteLine("I have {0} {1} ", DoorColor, DoorSize);
        }
        /// <summary>
        ///  Implement the Interface. Create a shallow copy of current object
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return this.MemberwiseClone();
        }

    }

public class Floor :ICloneable
    {
        public string FloorType
        {
            get;
            set;
        }

        public void Display()
        {
            Console.WriteLine("I have {0}  ", FloorType);
        }
        /// <summary>
        ///  Implement the Interface. Create a shallow copy of current object
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
public class Wall: ICloneable
    {
        public int WallHeight
        {
            get;
            set;
        }
        public int WallWidth
        {
            get;
            set;

        }
        public string WallType
        {
            get;
            set;
        }

        public void Display()
        {
            Console.WriteLine("I have {0} {1} {2} ",WallHeight,WallWidth, WallType);
        }
        /// <summary>
        ///  Implement the Interface. Create a shallow copy of current object
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return this.MemberwiseClone();
        }
    }
public class Window:ICloneable
    {
        public string WindowColor
        {
            get;
            set;
        }
       
        public string WindowType
        {
            get;
            set;
        }

        public void Display()
        {
            Console.WriteLine("I have {0} {1}  ",WindowColor,WindowType );
        }
        /// <summary>
        ///  Implement the Interface. Create a shallow copy of current object
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            return this.MemberwiseClone();
        }

    }

public class House : ICloneable
    {
        public Floor floor
        {
            get;
            set;
        }
        public Wall wall
        {
            get;
            set;
        }
        public Door door
        {
            get;
            set;
        }
        public Window window
        {
            get;
            set;
        }
        public string HouseName
        {
            get;
            set;
        }


        // default constructor.
        public House()
        {
            floor = new Floor();
            wall = new Wall();
            door = new Door();
            window = new Window();
        }

        // constructor to implement deep copy

        public House(House newhouse)
        {
            floor = newhouse.floor;
            wall = newhouse.wall;
            door = newhouse.door;
            window = newhouse.window;
            HouseName = newhouse.HouseName;
        }

        // Method to show the result
      
        public void Dispaly()
        {

            Console.WriteLine("I am  " + HouseName);
            floor.Display();
            wall.Display();
            door.Display();
            window.Display();

            Console.WriteLine();
        }

       
        //call deep coy to perform clone process
        public object Clone()
        {
            return new House(this);
        }



    }
}// end of namespace

class Program
    {
        static void Main(string[] args)
        {
           

            House house = new House();
            house.HouseName = "SankalpGad";
            house.floor.FloorType = "Glass Floor";
            house.wall.WallHeight = 15;
            house.wall.WallWidth = 5;
            house.wall.WallType = "Glass";
            house.door.DoorColor = "White";
            house.door.DoorSize = 8;
            house.door.DoorType = "Glass";
            house.window.WindowColor = "Black";
            house.window.WindowType = "Glass";

            House copiedHouse = (House)house.Clone();

            Console.WriteLine("Display the House");
            house.Dispaly();

            Console.WriteLine("Display the Copied House");
            copiedHouse.Dispaly();

            copiedHouse.HouseName = "New SankalpGad";
            copiedHouse.floor.FloorType = "Wooden Floor";
            copiedHouse.door.DoorType = "Wooden";

            Console.WriteLine("Display the Copied House after some changes.");
            copiedHouse.Dispaly();


           
        }
}

e.      Singleton Pattern: Singleton pattern is based on the concept of the restricting the instantiation of the class to the one object. Say one object will perform the role of the coordinator between various instances of the application that depend on a common object; we may design an application using a singleton. Usage of Singleton pattern in common in Banking, Finance and Travel base application where single object consist of Network related information. A singleton class may be used to instantiate an object of it, only if that object does not already exist. In case if the object exists the reference to the existing object is given. A single object has one global point of access to it.
In ASP.Net Web Farm is also based on singleton pattern. In web farm several applications resided on the web server. Session state is handled by singleton object in the form of aspnet_state.exe that interacts with aspnet_wp.exe running on each web server. Imagine one of the web server is shutting down, the singleton object still maintain the session state information across all web servers in the web farm.

namespace DesignPatterns.Creational.Singleton
{
    public class Singleton
    {
        private int intNumber;
        // declare the static object of singleton class.
        private static Singleton instance;

        public int Number
        {
            get
            {
                return intNumber;
            }
            set
            {
                intNumber = value;
            }
        }

        /// <summary>
        ///  Portected constructor of the Singleton Class.
        /// </summary>
        protected Singleton()
        {
        }

        /// <summary>
        /// To create the object of Singleton class.
        /// </summary>
        /// <returns></returns>
        public static Singleton Instance()
        {
            // if the object in Null then create a New object else return existing object.
            if (instance == null)
            {
                instance = new Singleton();
            }
            return instance;
        }

    }
}
class Program
    {
        static void Main(string[] args)
        {
           

Singleton singleobject = Singleton.Instance();
            Singleton singleobject1 = Singleton.Instance();
            if (singleobject == singleobject1)
            {
                Console.WriteLine("Object are same");

            }
            singleobject.Number = 2;

Console.WriteLine("SingleObject Number=" + singleobject.Number.ToString());

            singleobject1.Number = 5;

Console.WriteLine("SingleObject Number=" + singleobject.Number.ToString());

Console.WriteLine("Upated SingleObject Number=" + singleobject.Number.ToString());
           
        }
}