Tuesday, 15 December 2015

Liferay 7 - First look with basic explanation


Hello,

Today, first time I started Liferay 7 in my machine so thought to share basic walk through with Liferay 7 portal, in this walk through I have covered different sections of Liferay 7, play with couple of component like Blogs, Page, Document and Media,Control Panel, Mobile preview etc , Enjoy video !!

What version I have used in this video ? It is Lifeay 7 Alpha-2 Community Version

Where to download ? Well, I got it from Liferay team in Liferay Symposium workshop but I am sure you will find all latest LR7 community version here.

New features in Liferay 7, 
(Note : Trying to highlight as much as I know, there must be more than these for sure  )
  • Technically Liferay 7 has lot of new things like Micro services (Modularity) 
    • Means no more need of portlet.xml , liferay-portlet.xml etc
    • Everything is decoupled
  • Look and feel brand new (Please refer video)
  • Change in site template 
  • Configuration of navigation 
  • Create content is more easy with alloy editors 
  • Different view facilities like List, Descriptive, Icon view.
  • New localize language search
  • Approval workflow subscription base on folders
  • Geolocation content creation 
  • Blog experience is improved (Please refer video) 
  • End user interaction is improved like you can refer person with "@" annotation in comment section.
    • Ex. @Sagar Vyas
  • Document and Media library 
              Basic walk through of Liferay7 with brief description on each component.



Have a happy learning !!

Thanks,
Sagar Vyas

Monday, 14 December 2015

Java : Overriding and Overloading Concepts and Difference.

Hello friends, I know overloading/overriding are one of the famous OOB concepts that everyone knows JBut I feel more often people got confuse in this concepts.

Please go through the below diagram that will give you broad picture and lets understand point by point.




Overriding:

  • Overriding is runtime polymorphism
  • Happens in different class and Use in Inheritance : Overriding is concept that use in Inheritance where super class and sub class has same method name and same arguments
           Ex.
class Animal {
     public void myOverRiding ()
     {
      System.out.println("This is animal overriding ");
     }
}

class Horse extends Animal {
     public void myOverRiding ()
     {
      System.out.println("This is horse overriding ");
     }
}
  • Can we prevent overriding?
o   “Final” keyword can be prevent class to be inherited that means technically we are preventing overriding.
o   It will throw following compile time error.


  •  JVM decides what to do at run time: when you are calling any method with help of sub/super class object, JVM decides at run time that method of which class needs to be called
      public class UserAnimal {
     public static void main(String s[])
     {
           Animal aniHrnew Horse(); //Line 4
           aniHr.myOverRiding();
   //In overriding it will call actual object class method.
     }
}

class Animal {
     public void myOverRiding ()
     {
           System.out.println("This is animal overriding ");
     }
}
class Horse extends Animal {
    
public void myOverRiding ()
     {
          System.out.println("This is horse overriding ");
     }
}

                                In above example we have two classes Animal – Super class and Horse – Sub class which shares same method called myOverRiding() now in UserAnimal class we have created an object of Horse and reference of Animal (refer Line # 4) and we called myOverRiding() method with help of that object (aniHr) now question is, which class’s method myOverRiding() will be called ? Any guess?

     Answer, in overriding JVM runtime use actual object and in overloading JVM use reference (Animal) instead of actual object (Horse)


O/P:  This is horse overriding

Overloading:

  • Overloading is compile time polymorphism
  • Happens in same class only
  • Method can have same name and different arguments
   class Animal { 
   MyStuff() {  System.out.println("Hi Cow");  }
   MyStuff(int i) { System.out.println("Hi Dog");  }
  }

  • Can we prevent override? Unlike override prevent with final keyword with class , java don’t have anything to prevent overload in class (unless you wish to not write same method name J )
  • JVM decides everything at compile time : which class method needs to be called that will decide at compile time (in overloading JVM use reference (Animal) instead of actual object (Horse))
  • If you try to write same method with same arguments it will throw compile time error.
Ex.  This is the similar example which I have explained above just o/p is different

public class UserAnimal {
     public void doStuff(Animal a)
     {
           System.out.println("This is animal ");
     }
     public void doStuff(Horse a)
     {
           System.out.println("This is horse");
     }
     public static void main(String s[])
     {
           UserAnimal obj = new UserAnimal();
           Animal aniHrnew Horse();
           obj.doStuff(aniHr)
       //In overloading it will call reference class method.
     }
}
class Animal {
}
class Horse extends Animal {
}

O/P: This is animal

Hope this article would be value added and helpful, have a happy learning J

Thanks,
Sagar Vyas