Tuesday, July 13, 2010

Have Darshan, Get the Message & Be Blissful on the Eve of World Famous Car Festival (Ratha Yatra) 2010

jagannath_Krishna.jpg


Jay Jaganatha Swami,
Nayana Patha Gami.

Bhava Tume Bhaba tume, Bhava Tume....

Wishing all spiritual soul, a Happy & blissful Ratha Yatra....
For Live telecast (open in IE) : http://rathjatra.nic.in/live2010b.htm
The concept of the chariot has been explained in the Kathopanishada in the following words-
Atmanam rathinam viddhi sareeram rathamevatu
Buddhim tu saarathim viddhi marah pragrahameva cha.
Purport
The body is the Chariot and the soul is the deity installed in the chariot. The wisdom acts as the charioteer to control the mind and thoughts.

May Lord JagaNatha fill our life with right knowledge for a happy & peaceful life...
Pabitra Ratha Yatra ra Hardika Subhakamana ...
Hare Krishna :-)
rath3.jpg
For Live telecast (open in IE) : http://rathjatra.nic.in/live2010b.htm
Rathas.jpg

Lord+jagannath+Wallpaper.gif

Friday, July 9, 2010

Dependency Injection, Problem statement & solution through an example in C#.

Dependency Injection:

In Which scenario we should opt for Dependency Injection???

Problem

You have classes that have dependencies on services or components whose concrete type is specified at design time. In this example, ClassA has dependencies on ServiceA and ServiceB. Figure 1 illustrates this.
Ff649378.4722b85b-ac16-4e68-b46d-c70e52adcd72(en-us,PandP.10).png
Figure 1
ClassA has dependencies on ServiceA and ServiceB
This situation has the following constraints:
  • To replace or update the dependencies, you must change your classes' source code.
  • The concrete implementation of the dependencies must be available at compile time.
  • Your classes are difficult to test in isolation because they have a direct reference to their dependencies. This means that these dependencies cannot be replaced with stubs or mocks.
  • Your classes contain repetitive code for creating, locating, and managing their dependencies.

Forces

Any of the following conditions justifies using the solution described in this pattern:
  • You want to decouple your classes from their dependencies so that these dependencies can be replaced or updated with minimal or no changes to your classes' source code.
  • You want to be able to write classes that depend on classes whose concrete implementation is not known at compile time.
  • You want to be able to test your classes in isolation, without using the dependencies.
  • You want to decouple your classes from being responsible for locating and managing the lifetime of dependencies.

Solution

Do not instantiate the dependencies explicitly in your class. Instead, declaratively express dependencies in your class definition. Use a Builder object to obtain valid instances of your object's dependencies and pass them to your object during the object's creation and/or initialization. Figure 2 illustrates this.
Ff649378.360cdd41-4418-4fff-9dee-fc6140458c1d(en-us,PandP.10).png
Figure 2
Conceptual view of the Dependency Injection pattern
Ff649378.note(en-us,PandP.10).gifNote:
Typically, you express dependencies on interfaces instead of concrete classes. This enables easy replacement of the dependency concrete implementation without modifying your classes' source code.
The following are the two main forms of dependency injection:
  • Constructor injection
  • Setter injection
In constructor injection, you use parameters of the object's constructor method to express dependencies and to have the builder inject it with its dependencies. In setter injection, the dependencies are expressed through setter properties that the builder uses to pass the dependencies to it during object initialization.

Implementation Using the Unity Application Block

The Dependency Injection pattern can be implemented in several ways. The Unity Application Block (Unity) provides a container that can be used for dependency injection. For more information about the Unity Application Block, see Unity Application Block.

Example

The NewsReaderPresenter class of the Stock Trader Reference Implementation (located at StockTraderRI.Modules.News\Article\NewsReaderPresenter.cs) uses constructor dependency injection to obtain a valid instance of a view that implements the INewsReaderView interface. The class definition is shown in the following code.
public class NewsReaderPresenter : INewsReaderPresenter
{
    private INewsReaderView readerView;

    public NewsReaderPresenter(INewsReaderView view)
    {
        this.readerView = view;
    }

    public void SetNewsArticle(NewsArticle article)
    {
        readerView.Model = article;
    }

    public void Show()
    {
        readerView.ShowView();
    }
}
Because the NewsReaderPresenter class uses dependency injection to obtain its dependencies, its dependencies can be replaced with mock implementations when testing. The following test methods, taken from the fixture file StockTraderRI.Modules.News.Tests\NewsView\NewsReaderPresenterFixture.cs, show how the NewsReaderPresenter class can be tested in isolation using mock implementations to replace the classes' dependencies and verify behavior.
[TestMethod]
public void ShowInformsViewToShow()
{
    var view = new MockNewsReaderView();
    var presenter = new NewsReaderPresenter(view);

    presenter.Show();

    Assert.IsTrue(view.ShowViewWasCalled);
}

[TestMethod]
public void SetNewsArticlesSetsViewModel()
{
    var view = new MockNewsReaderView();
    var presenter = new NewsReaderPresenter(view);

    NewsArticle article = new NewsArticle() { Title = "My Title", Body = "My Body" };
    presenter.SetNewsArticle(article);

    Assert.AreSame(article,view.Model);
}

Liabilities

The dependency injection pattern has the following liabilities:
  • There are more solution elements to manage.
  • You have to ensure that, before initializing an object, the dependency injection framework can resolve the dependencies that are required by the object.
  • There is added complexity to the source code; therefore, it is harder to understand.

Related Patterns

The following patterns are related to the Dependency Injection pattern:
  • Inversion of Control. The Dependency Injection pattern is a specialized version of the Inversion of Control pattern where the concern being inverted is the process of obtaining the needed dependency.
  • Service Locator. The Service Locator pattern solves the same problems that the Dependency Injection pattern solves, but it uses a different approach.

More Information

For more information on the Dependency Injection pattern, see the following:

Effective ways to handell worrying situations!!! It really works, Try it out :-)

Recently I saw a survey that says:

  • 40 percent of the things we worry about never happen,
  • 30 percent are in the past and can't be helped,
  • 12 percent concern the affairs of others
  • 10 percent are about sickness--either real or imagined
  • 8 percent are worth worrying about.
I would submit that even the 8 percent aren't really worth the energy of worry.

Did you know that the English word worry is derived from an Anglo-Saxon word that means to strangle or to choke? That's easy to believe. People do literally worry themselves to death leading to heart disease, high blood pressure, ulcers, nervous disorders and all sorts of other diseases. Is it worth it?
   
We just need to find a way to keep it from ruling our lives.


Try this:
  • Analyze the situation honestly and figure out what is the worst possible thing that could happen.
  • Prepare yourself mentally to accept the worst, if necessary.(But must keep the expectation & moral as high as possible).
  • Then calmly try to improve upon the worst, which you have already agreed mentally to accept.
  • You know what you have to do; it's just a matter of doing it. Without worrying.
  • The last but not least, if you have immense faith on God, then certainly you can feel his blessings protecting you in every chaotic situations, though sometimes it reflects bit late. So just have patience, "God has His own way of making things perfect". 
  • We just have the right to keep performing our duty nicely. Fruit of action, whether good or bad is up to God, based on our past Karma. So instead of worrying if we can focus on our course of action to make things better, it will help very fast, else the worry will keep destroying our energy, enthusiasm & we will end up nowhere.
The point is, you can't saw sawdust. A day of worry is more exhausting than a day of work. People get so busy worrying about yesterday or tomorrow, they forget about today. And today is what you have to work with.

Next time when you observe that u start worrying for something, just back up & analyze it a bit... Apply the above points & I am sure it will help... 

I am getting immense benefit & hope the same works for you too :-)


Hare Krishna :-)

How to get good sleep?

1. Try relaxation & deep breathing exercises

Put things into perspective before you become upset or angry. Look into some relaxation techniques and deep breathing exercises.

2. Exercise regularly

Exercise increases heart and lung fitness while reducing stress, anxiety and insomnia. It also raises your endorphin levels -- the natural "mood elevators" produced by the brain. Endorphins reduce pain, relax muscles, and produce feelings of well being. As a result, sleep will be deeper and more restful. Even something as simple as brisk walking can have a positive effect, if done regularly.

3. Keep mentally stimulated

Boredom can actually keep you awake! If you’re physically and mentally active, you’re less likely to have poor sleep problem.

4. Eat properly

Limit your intake of fat and fried foods. Avoid eating a large or heavy meal within two to three hours of bedtime. While such a meal can make you feel drowsy at first, you’ll probably toss and turn during the night.

5. Take a warm bath before bed

Just before bedtime (1-2 hours before sleeping), take bath with warm water. This will send blood away from the brain to the skin surfaces, and make you feel relaxed and drowsy. Your body temperature, raised by the warm water, will soon drop if you have a moderately cool bedroom. This will initiate sleepiness and more deep sleep.

6. Establish a bedtime ritual

Establish a bedtime ritual. Read Bhagavad-gita or other good books. Take your mind off the day’s busy-ness by venturing into the sublime thoughts.

Thursday, July 8, 2010

Do some analysis, before you go for any investments!!!




Hi friends,
   Generally we have the tendency to invest either in Fixed deposits or in such Mutual funds, where our friend's or colleges are investing. But careful analysis before any investment can make a huge difference in terms of returns, of course in long run ... :-)


I can see, there is considerable difference in returns ( In three to five years), incase of all premium mutual funds / AMCs.
I have done some analysis based on Asset size & consistent ROR (Rate of Return) and found the below funds are good to invest:



1.       HDFC Tax Saver (G)
3.       Sundaram Tax Saver (G)
4.       Religare Tax Plan (G)

The below funds are more aggressive & volatile in nature. You can expect better Returns, but also bit risky J

1. Can Robeco Eqty TaxSaver (G) http://www.moneycontrol.com/images/mf/bypost.gif
2. Sahara Taxgain (G)



 For further analysis U can refer sites like Moneycontrol.com



Click http://www.moneycontrol.com/mutual-funds/performance-tracker/eqt/ab/im_asstsize

In my next article I will try to showcase some input on ULIP's pros & cons.
Also about credit card security in India & its benefit in current scenario.

Hope the article will be helpful :-)

 Thanks& regards,
 Bikash Patra
+91-9036113317