Onclick Link Disabling With jQuery

Days back I have come across a common requirement to disable link on clicking it once. Typically, it’s because on click of those links some AJAX thins happen and some fragments of the page gets updated.

If Else or Switch Case to Polymorphism

If you try to express your logic in if-else way like this,

  private static String getSoundIfElseWay(String animal) {
       if (animal.equalsIgnoreCase("Dog"))
            return "Bark";
       else if (animal.equalsIgnoreCase("Cat"))
            return "Mew";
       else if (animal.equalsIgnoreCase("Lion"))
            return "Roar";
       return "";

then polymorphic way would be,