Saturday, November 10, 2012

Multiple Implementation


Hello Friends,

Below program describes, how to implement multiple interfaces in C#. Specially when two interfaces having same method name, then  how to resolve the conflict in multiple implementation, this is shown in below code.
Please also mark that C# and JAVA don't support multiple inheritance, but support multiple implementation. We inherit the classes but implement the interfaces. This particular word "Inherit" should not be used in case of implementing the Interfaces.
Feel free to comment:



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleMultipleInheritance
{

    interface InterfaceA
    {
        void methodA();
        void methodB();
        void methodC();

    }

    interface InterfaceB
    {
        void methodC();
        void methodD();
        void methodE();
    }
   
    abstract class absA
    {
        //Note: 1. Virtual method can be used with abstract 
        // as well as simple class.
        //2. Virtual methods don't need to be override, its upto the programmar.
        //3. Virtual Methods need to have body, means they need to 
        // have definition.
        public virtual void methodG()
        {
        }

        //Note: 1. Abstract method can be used only with abstract class
        //2. Abstract methods need to be override, its hard and fast rule.
        //3. Abstract methods can not have body. They should 
        //be just created without definition inside abstract class only. 
        //Note: If an abstract class will have only abstract members e.g.
        //abstract methods, properties, 
        //then I guess that will work as Interface. Do some googling
        //on Interface vs fully abstract class
        public abstract void methodC();

        }

    class drvdA : absA, InterfaceA, InterfaceB
    {
        public void methodA()
        {
            Console.WriteLine("method A");
        }
   
        public void methodB()
        {
            Console.WriteLine("method B");
        }

        public void methodD()
        {
            Console.WriteLine("method D");
        }

        public void methodE()
        {
            Console.WriteLine("method E");
        }

        public void methodF()
        {
            Console.WriteLine("method F");
        }


       // We don't need to override the virtual function.
       // Its upto the programmar  
        // public override void methodG()
        //{
        //    Console.WriteLine("method G");
        //    //base.methodG();
        //}

        public override void methodC()
        {
            Console.WriteLine("Abstract Class method C");
            //base.methodG();
        }


        // This is how we call the common methods of Interfaces 
        // which we implemented in our class. We use fully qualified name.
        
         void InterfaceB.methodC()
         {
             Console.WriteLine("InterfaceB method C");
          
         }

         void InterfaceA.methodC()
         {
             Console.WriteLine("InterfaceA method C");

         }

    }
   
    //Empty class inheriting another class which is not empty
    class drvdB : drvdA
    { }

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

            //Execution Time Calculation
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            Console.WriteLine("ABC");
            sw.Stop();
            Console.WriteLine(sw.Elapsed );
           
            sw.Start();
            Console.WriteLine("ABC");
            sw.Stop();
            Console.WriteLine(sw.Elapsed);
           
            //making instance of derived empty class
            drvdB b = new drvdB();

            //Able to get the methods of base class which are not implemented
            // into derived class
            b.methodA();
            drvdA a = new drvdA();
           
            a.methodA();
            a.methodB();
            a.methodC();
            a.methodD();
            a.methodE();
            a.methodF();
            a.methodG();
            //Calling those methods which are implemented from Interfaces,
            // through the instance of its derived class...
            ((InterfaceA)a).methodC();
            ((InterfaceB)a).methodC();
            Console.Read();
            //ConstructorStrategy cs = new ConstructorStrategy();

        }
    }
}




Sunday, May 20, 2012

Success


These thoughts came into my mind when I was watching the Race competition between athletes. I tried to contemplate what exactly an athlete would have the status of mind in the whole process of racing. I sincerely feel that the same attitude and thoughts can be applied for every work we take in our hand to complete:

1.      Clarity of Goal: We are very clear about our destiny point where we have to reach. That destiny point is our Goal. So put this goal into sub-conscious mind.

2.      Clarity in the Process of Achieving the Goal: Our lap and small strip where we have to run is predefined and we are very much clear that what we have to do to reach to our destiny point. We just have to start running. So put the process of running into conscious mind and utilize whole energy and concentration in running only.

3.      Deviating Factors: While running, we can’t waste our energy and concentration to see how many of our opponents are progressing or regressing how much with us. If we do that, we will certainly lose our concentration and balance on running, we may fell down because we may lose our strip where we are running by overlapping with the strips of others, we will waste a lot of our valuable energy and concentration by doing this which we can utilize in running and at last we will lose the game. So we can’t waste such valuable energy and concentration by having our eyes on others status. If we do a little bit of contemplation on this, we will find that it’s of no use to be aware about our status compared with our opponents. We did this either because of our fear factor of losing the game or because of curiosity to know where we are in the race or we have the attitude of competing with others. But all of these factors don’t help us on winning. We have to suppress our fear and curiosity while running and need to change our attitude of competing with others. When at some point of time if we choose to compete with others, it will certainly have two drawbacks:

a.       When we will see that we are progressing with our opponents, we may feel too much secured, confident, encouraged and may be some amount of arrogance that we may stop utilizing our whole capability in process of running, which is necessary to win the race. This may lead us to lose the game.

b.      When we will see that we are regressing with our opponents, we may feel discouraging and depressing and may stop using our whole capability. This is the biggest defeat of ours and our attitude of perseverance which leads us nowhere but to only misery and sufferings.  This discouragement just leads us with a life without energy and fighting attitude. Such life is a life without life.

So in both condition when we compete with others we lose the battle. So we have to compete with ourselves only by utilizing our whole energy, concentration and will power in the process of running till we reach the destiny point.

4.      When we run in the race with having such attitude described above, whether we win or lose the game, but at last we feel the peace because we are very much aware that we did our best. And this peace is the factor which really matters in our life, because as Swami Vivekananda says:
Peace is the highest form of Strength. Strength is life and weakness is death

             Swami Vivekananda’s quote on the perspective of achieving goal:
Take up one idea. Make that one idea your life - think of it, dream of it, live on that idea. Let the brain, muscles, nerves, every part of your body, be full of that idea, and just leave every other idea alone. This is the way to success.
Arise! Awake! And stop not till the goal is reached…




Tuesday, April 24, 2012

Free Will and Self Responsibility



This article is dedicated to one martyr, freedom fighter, I cannot recall his name. He was doing exercise before he was getting hanged. So the jailor asked him, “Why you are doing exercise as you are already aware that you will be getting hanged just in few moments”. He said, “Whenever I will born in my mother land, I will have such great mental and physical strength that I have at this life and I would be able serve my country with same zeal and conquer.”


So, getting hanged may be our destiny but getting hanged peacefully, fearlessly can be our freewill. We may be destined with weak body, mind, unfriendly physical environment, but we can have freewill to do sheer struggle and overcome from all sufferings and miseries. This freewill is free from all negative forces too:


1.     Luck


2.     Fate


3.     Astrology


4.     Effects of past deeds as well as previous life deeds


5.     All types of tantra, mantra and yantra


6.     All the forces led by the enemies of God.


But, our human mind is weak and the forces of inertia always try to overpower our free will. Whenever some problems or issues encounter into our life, we always try to find excuses of sufferings using above forces or try to impute on others. But as Vedanta said whatever we get in present, is solely dependent on our own past deeds. So whatever we do at present will build our future. I can remember below quotes of Swami Vivekananda which is about self responsibility:


Say, ‘This misery that I am suffering is of my own doing, and that very thing proves that it will have to be undone by me alone.’ That which I created, I can demolish; that which is created by someone else, I shall never be able to destroy. Therefore, stand up, be bold, be strong. Take the whole responsibility on your own shoulders, and know that you are the creators of your own destiny. All the strength and succour you want is within ourselves


We are responsible for what we are, and whatever we wish ourselves to be, we have the power to make ourselves. If what we are now has been the result of our own past actions, it certainly follows that whatever we wish to be in future can be produced by our present actions; so we have to know how to act.”


So whenever we think that we are weak because we are destined to be, or it’s our luck or fate or it’s because of our own deeds of past or previous life, or it’s because of curse or evil thought of others, we should remember above quotes of Swami Vivekananda and take the responsibility.  


So, struggle from this very moment to get rid of all sufferings. Struggle till the mind is able to think and body is able to breathe.


As soon as we embrace the struggle, the negative forces will try to overpower our free will. Off course they have to be, because we need to pay the cost for Freedom. We have to be very firm and develop the attitude of perseverance. After some time negative forces will start vanishing and replaced by positive forces.  We need to remember that Freedom is very expensive and we will value it only when we will do enough struggles to get it. Otherwise we will never realize how important they are in our life.


So at last the conclusion is:


We always do excuses and/or try to impute on others about our miseries and sufferings. But this is not the cure of sufferings. We have to take all responsibilities of sufferings and develop strong free will to act positively from this very moment, so that future would be bright and delightful. Because future is dependent on our present deeds as present is dependent on our past deeds. We need to remember that there are no destiny or negative forces which can overpower the freewill and perseverance. At last, all the very best to everybody in path of freedom.

Monday, April 16, 2012

Great Quotes


These are the collection of some great quotes:

You open your arms wide, and you set me free. You don't hold me tight, so I suffocate in your love. You set me free so I can fly. And you are not afraid. Not afraid that I will leave you. You will be sad if I do, and certainly you do not want it. But it is my happiness that comes first for you. Not your fear. And I do not leave. How could I? And where would I go? I have finally found home. The home I have been searching for eternity. You are my home, my love. This is where I belong with you. Right here in your arms. - Unknown


Stand up, be bold, and take the blame on your own shoulders. Do not go about throwing mud at others; for all the faults you suffer from, you are the sole and only cause.- Swami Vivekananda


Do not believe anything blindly, because your ancestors used to believe it.
Do not believe anything blindly because it’s written in your religious tomes. Do not believe anything blindly because it’s your national belief. But before believing, first judge it, practice it and live upon it. And after you find anything useful then take it as well as give it to all and be in peace. 
- Lord Buddha (Taken from book "Message of Lord Buddha" written by Swami Vivekananda)

Be the change you seek in the world- Mahatma Gandhi

Everyone thinks of changing the world., but no one thinks of changing himself. – Leo Tolstoy


Vision without action is a daydream. Action without vision is a nightmare. – Japanese Proverb


Security is mostly a superstition. It does not exist in nature, nor do the children of men as a whole experience it. Avoiding danger is no safer in the long run than outright exposure. Life is either a daring adventure, or nothing. - Helen Keller

The most important thing a father can do for his children is to love their mother. –Unknown

He who stops being better, stops being good. - Oliver Cromwell

If you are not progressing and feeling that you are constant that means you are actually lagging behind.- Unknown

The time is always right to do what is right. –Martin Luther King, Jr.


Smile! And the world will smile with you. – Unknown

I expect to pass through this world but once; any good thing therefore that I can do, or any kindness that I can show to any fellow creature, let me do it now; let me not defer or neglect it, for I shall not pass this way again. - Stephan Grellet quotes

Nothing can stop the man with right mental attitude from achieving his goal; nothing on earth can help the man with the wrong mental attitude. – Thomas Jefferson

If you don’t like something, change it. If you can’t change it, change your attitude. – Maya Angelou

Life is no brief candle for me. It is a sort of splendid torch which I have got a hold of for some moment, and I want to make it burn as brightly as possible before handing it to future generations. – George Bernard Shaw

Tough time never last but tough people do. – Robert Schuller

Wisdom is knowing what to do next. - David Starr Jordan

Your talent is God’s gift to you. – Leo Buscaglia

Always do right; this will gratify some and astonish the rest. – Mark Twain

Be happy for this moment. This moment is your life. – Unknown

We will either find a way or make one. – Hannibal

You can do anything you put your mind to. – Unknown

The only good luck many great men ever had was being born with the ability and determination to overcome bad luck.- Channing Pollock


The definition of insanity is doing the same thing over and over again and expecting different results. –Albert Einstein


Most of the important things in the world have been accomplished by people who have kept on trying when there seemed to be no hope at all. – Dale Carnegie


Dreams are renewable no matter what our age. – Dale Turner


Nothing in the world can take the place of Persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination alone are omnipotent. - Calvin Coolidge

The best way to predict the future is to create it. - Peter F. Drucker

Pain is inevitable, suffering is option.- Unknown

I believe that it is better to tell the truth than a lie. I believe that it is better to live free than to be a slave. And I believe it is better to know than to be ignorant. – H. L. Mencken

The quality of a person’s life is in direct proportion to their commitment to excellence, regardless of their chosen field of endeavor. – Vince Lombardi

Friends are angels who lift us to our feet when our wings have trouble remembering how to fly. – Unknown

Regret for the things we did can be tempered by time; it is regret for the things we did not do that is inconsolable. – Sydney Harris

Character cannot be developed in ease and quite. Only through experience of trial and suffering the soul be strengthened, ambition inspired and success achieved. – Helen Keller

Great works are performed not by strength but by perseverance. – Samuel Johnson

It is never too late to be what you might have been. – George Eliot

Try not to become a man of success but rather try to become a man of value. – Albert Einstein

Minds are like parachutes they only function when they are open. – Thomas Dewar

The price of success is hard work, dedication to the job at hand, and determination that whether we win or loose, we have applied the best of ourselves to the task at hand. – Vince Lombardi

Watch your thoughts; they become words. Watch your words; they become actions. Watch your actions; they become habits. Watch your habits; they become character. Watch your character; it becomes your destiny. – Frank Outlaw

Our glory is not in never falling, but in rising every time we fall. -Confucious

The road to success is always under construction. – Unknown

Some people dream of success while others wake up and work hard at it. –Unknown

If you think you are beaten, you are. If you think you dare not, you don’t. If you would like to win, but think you can’t. It’s almost a cinch you won’t. Life’s battle don’t always go to stronger or faster man; but soon or late to the man who wins is the one who thinks he can. – Unknown

There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group, there is less competition there. – Indira Gandhi

Well done is better than well said. – Benjamin Franklin

Change comes from within. - Unknown

Procrastination is the thief of time. –Edward Young

Too often we underestimate the power of a touch, a smile, a kind word, a listening ear, an honest compliment, or the smallest act of caring, all of which have the potential to turn the life around.- Leo Buscaglia

You can make more friends in two months by becoming interested in other people than you can in two years by trying to get other people interested in you. – Dale Carnegie

The mediocre teacher tells. The good teacher explains. The superior teacher demonstrates. The great teacher inspires. – William A. Ward

It is our choice, Harry, that shows what we truly are, far more than our abilities. - Professor Albus Dumbledore (Harry Potter Movie)

I believe that unarmed truth and unconditional love will have the final love in reality. That is why right, temporarily defeated, is stronger than evil triumphant. - Martin Luther King, Jr.

If not us, who, if not now, when? – Unknown

Far better is it to dare mighty things, to win glories triumphs, even though chequered by failure, than to take rank with those poor spirits who neither enjoy much nor suffer much, because they live in the grey twilight that knows not victory or defeat. – Theodore Roosevelt

Twenty years from now you will be more disappointed by the things you didn’t do than by the ones that you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. – Mark Twin


You cannot escape the responsibility of tomorrow by evading it today. – Abraham Lincoln


When one door closes another opens, but we often look so long and so regretfully upon the closed door that we do not see the one which has opened for us. – Alexander Graham Bell


You attitude determines your altitude. - Zig Ziglar


Attitude is a little thing that makes a big difference. – Sir Winston Churchill


There are two ways to live your life. One is as though nothing is a miracle. The other is as though everything is a miracle. – Albert Einstein


Am I not destroying my enemies when I make friends of them? – Abraham Lincoln


Everything is okay in the end. If it’s not okay, then it’s not the end. – Unknown


How far you go in life depends on you being tender with the young, compassionate with the aged, sympathetic with the striving and tolerant of the weak and the strong. Because someday in life you will have been all of these. – George Washington Carver


Be bold and mighty forces will come to your aid. – Johann Wolfgang von Goethe


I know God will not give me anything I can’t handle. I just wish he didn’t trust me so much. – Mother Teresa


Action may not always bring happiness; but there no happiness without action. – Benjamin Disraeli



I matter of style swim with current. In matter of principle, stand like a rock. – Thomas Jefferson


It’s never too late to be what you might have been. – George Eliot


You can have anything you want -if you want it badly enough. You can be anything you want to be, do anything you set out to accomplish if you hold to that desire with singleness of purpose. - Abraham Lincoln


The greater the obstacle the more glory. - Moliere


When you get into a tight place and everything goes against you, till it seems you cannot hold on a minute longer, never give up then for that is just the place and time the tide will turn. – Harriet Beecher Stowe


The whole art of teaching is only the art of awakening the natural curiosity of young minds for the purpose of satisfying it afterwards. – Anatole France


Being defeated is often a temporary condition. Giving up is what makes it permanent. – Marilyn Vos Savant


Its not that I am so smart, it’s just that I stay with problems longer. – Albert Einstein


I am a great believer of luck and I find that the harder I work the more I have of it. – Thomas Jefferson


If we don’t change, we don’t grow. If we don’t grow, we aren’t really living. – Gail Sheehy


He who asks a question is fool for five minutes. He who does not ask a question remains fool forever. – Chinese Proverb


Optimism is the faith that leads to achievement. Nothing can be done without hope or confidence. – Helen Keller


Whenever you are asked if you can do a job, tell them, Certainly I can! – and get busy and find out how to do it.– Theodore Roosevelt


You must do the things you think you cannot do. – Eleanor Roosevelt


Victory belongs to the most persevering. – Napoleon Bonaparte


Great minds have purposes, other have wishes. – WashingtonIrving


Strength does not come from winning. You struggle develop your strength. When you go through hardships and decide not to surrender, that is strength. – Mahatma Gandhi


Be more concerned with your character than your reputation, because your character is what you really are, while your reputation is merely what others think you are. – John Wooden


He who never made a mistake never made a discovery. - Samuel Smiles


Don’t go through life, grow through life. – Eric Butterworth


If money is your hope of independence, you will never have it. The only real security than a man can have in this world is a reserve of knowledge, experience and ability. – Henry Ford


The harder you fall the higher you bounce. - Horace


Education is not filling a bucket, but lighting a fire. – William Yeats


Whatever the mind can conceive and believe, it can achieve. - Napoleon Hill


Success is the sum of small efforts, repeated day in and day out. – Robert Collier


Failure is only the opportunity to begin again more intelligently. –Henry ford

Live in such a way that you would not be ashamed to sell your parrot to the town gossip. –Will Rogers

Our aspirations are our possibilities. – Robert Browning

Whatever comes our way... whatever battle is raging inside us, we always have a choice. My friend Harry taught me that. He chose to be the best of himself. It’s the choices that make us what we are... and we can always choose to do what's right. – Spiderman 3 Quote


Thanks,
Murali Darshan


My Queries on Spiritual Principle

Followings are my queries on spiritual principals:

1. Why a soul indulges itself into the cycle of birth and death? After
indulging, why the soul wants to free itself?
Is soul a fool or it’s the wish of God? But why God will ask the soul
to suffer? What god wants to prove by doing this?

2. Also the number of souls are constant or its varying. As we know many
species are ended. So if one species is ended then, the soul has to
take birth one time less, or its contant. But How the number of birth
can be constant if there is no species of that kind.
My questions might be full of immaturity as I have to read a lot on this field.

Thanks,
Murali Darshan