Spring vs EJB

App servers written to support the EJB standard can, in theory, be ported from one compliant Java EE app server to another. But that means staying away from any and all vendor-specific extensions that lock you in to one vendor.

Spring ports easily between app servers (e.g., WebLogic, Tomcat, JBOSS, etc.) because it doesn’t depend on them

Spring Boot offers an even better way to write applications without Java EE app servers. You can create an executable JAR and run it on a JVM.

The Spring framework sits on top of the application servers and service libraries. Service integration code (e.g. data access templates) resides in the framework and is exposed to the application developers. In contrast, the EJB 3 framework is integrated into the application server and the service integration code is encapsulated behind an interface. EJB 3 vendors can thus optimize the performance and developer experience by working at the application server level. For example, they can tie the JPA engine closely to JTA transaction management. Another example is clustering support which is transparent to EJB 3 developers

Spring vs J2EE

Strictly speaking, Spring is a framework while Java EE is a specification which is implemented by various softwares such as JBoss and Glassfish.
The greatest difference is that Spring is an actual library while JavaEE is an API that has to be implemented. Depending on the JAVA EE container you could find a full implementation (e.g. Glassfish), a partial implementation (e.g. Tomcat) a full implementation with extra sugar (e.g. JBoss and others).

Design Thinking is not about problem solving. Its about making things better. Fixing a Car which got broke down is problem solving. Fixing a Car to run smoothly and fuel efficiently is Design Thinking

Key Points

  • Learn to Fail Early
  • Test your end result.Make sure you are doing the right one
  • Don’t spend too much time on Planning. Start working

Other Notable Things

  • Ask questions not with solutions which you already have in your mind
  • Questioning Basics

    • What you think about It
    • What you feel about It
    • What you do about It
  • People hesitate to tell No.So you need to change the question according to that. Eg – Petrol Bunk Story – There was high turn around in petrol bunk for special petrol when “Shall I put Special Petrol” was asked instead of asking “Sir special or normal petrol” to customer. Instead of giving option to choose from ask shall I offer that. The one which you offer is the one which you like to sell
  • Empathy – Understanding how other people feel, communicating your understanding, Apathy – a state of not caring, being unsympathetic or not empathetic, Sympathy – feelings of pity and sorrow for someone, Antipathy – Glad they have those problems
  • Convert Implicit needs to Explicit Requirements Eg – TV not clear is a Implicit need to someone and TV to be bought is a requirement to someone.Turn Implicit needs of customers to explicit needs to make it as selling point

Is it possible to create Object for abstract class?

abstract class my {
    public void mymethod() {
        System.out.print("Abstract");
    }
}

class poly {
    public static void main(String a[]) {
        my m = new my() {};
        m.mymethod();
        System.out.println(m.getClass().getSuperclass());
    }
}

No, we can’t.The abstract super class is not instantiated by us but by java.

In the above code we are creating object for anonymous class.

my m = new my() {};

When the above code is compiled will result in following class file creation

My.class
Poly$1.class  // Class file corresponding to anonymous subclass
Poly.class

anonymous inner type allows you to create a no-name subclass of the abstract class

When the above code is run the output would be

Output

 Abstract
 class my

Now lets override the method in anonymous inner class like one below.

abstract class my {
    public void mymethod() {
        System.out.print("Abstract");
    }
}

class poly {
    public static void main(String a[]) {
        my m = new my() {
          public void mymethod() {
               System.out.print("Overridden in anonymous class");
           }
        };
        m.mymethod();
        System.out.println(m.getClass().getSuperclass());
    }
}

Output

 Overridden in anonymous class
 class my

Anonymous inner class with same name as abstract class are child classes of abstract class.

There may be times where one may think that I can extend parent class instead of implementing interface. Lets see whats When to choose inheritance over an interface and interface over inheritance.

inheritance over an interface
The main drawback of interfaces is that they are much less flexible than classes when it comes to allowing for the evolution of APIs. Once you ship an interface, the set of its members is fixed forever. Any additions to the interface would break existing types implementing the interface.

A class offers much more flexibility. You can add members to classes that you have already shipped. As long as the method is not abstract (i.e., as long as you provide a default implementation of the method), any existing derived classes continue to function unchanged.

interface over inheritance
Lets take the following code

Mammal.java

public abstract class Animal
{
 public void abstract mate();
 public void abstract feed();
}

Now the above abstract class has two methods mate() and feed().

public class Dog extends Animal
{
}

public class Cat extends Animal
{
}

Now we have Dog and Cat concrete classes extending Animal.

we have few more classes extending Animal

public class Giraffe extends  Animal{}
public class Rhinoceros extends  Animal{}
public class Hippopotamus extends  Animal{}

Now the classes Dog and Cat are pet animals. So it should implement pet behavior. This can be done in two ways.

  1. By defining isPet() method in base class and overriding in child class
  2. By implementing pettable interface.

Now implementing interface is easy compared to overriding method defined in base class because

  1. Interface favours clean code. Defining and Overriding the class may increase code redundancy
  2. Now you get a parakeets which is again a pet and could also fly.If you are inheriting the base class then you need to add canFly() method in base class and set it to return false and override in the parakeets class to return true.

    public class  parakeets extends Animal
    {
      .
      .
        public boolean canFly()
        {
            return true;
        }
    }
    

    Instead you can declare a interface flyable and implement the interface method without making changes to base class

    public class  parakeets extends Animal implements flyable 
    {
      .
      .
        public boolean canFly()
        {
            return true;
        }
    }
    
  3. Interface may be completely not related to class in which it is implemented. Say lets define a carpenter ants class which always moves one after another.Now this can be represented to implement queuing interface which has nothing to do with other animals other then carpenter ants since only ants of this type follows a queue system when they migrate from one place to another

Scenario 1:
If you have a clear analysis and Design in UML then you can start with the interface.

Scenario 2:
The interface shows up when you need to refactor common features out of several classes.Until you have multiple classes with common features, it’s hard to foresee what the interface should be.

Write a class and extract interface later. Usually the reason for extracting an interface is the need for a second implementation of that interface (often as a mock for unit testing)

[content_protector password=”@pple” identifier=”mugil” cookie_expires=”3600″ ajax=”true”]
http://www.javased.com/index.php?api=org.apache.poi.hssf.usermodel.HSSFFont

“Economic Times Notes”

[gdoc key=”https://docs.google.com/spreadsheets/d/16dFWCuGmc8ZniJ-DRAfh2P4cnf9lbeE2z-l30NPXnCQ/edit?usp=sharing”]
[/content_protector]

Maven acts as both a dependency management tool – it can be used to retrieve jars from a central repository or from a repository you set up – and as a declarative build tool. The difference between a “declarative” build tool and a more traditional one like ant or make is you configure what needs to get done, not how it gets done. For example, you can say in a maven script that a project should be packaged as a WAR file, and maven knows how to handle that.

Maven relies on conventions about how project directories are laid out in order to achieve its “declarativeness.” For example, it has a convention for where to put your main code, where to put your web.xml, your unit tests, and so on, but also gives the ability to change them if you need to.

Mutual funds vs hedge funds

Similarities:

Both mutual funds and hedge funds are managed portfolios. This means that a manager (or a group of managers) picks securities that he or she feels will perform well and groups them into a single portfolio. Portions of the fund are then sold to investors who can participate in the gains/losses of the holdings. The main advantage to investors is that they get instant diversification and professional management of their money.

Differences:
Hedge funds are managed much more aggressively than their mutual fund counterparts. They are able to take speculative positions in derivative securities such as options and have the ability to short sellstocks. This will typically increase the leverage- and thus the risk – of the fund. This also means that it’s possible for hedge funds to make money when the market is falling. Mutual funds, on the other hand, are not permitted to take these highly leveraged positions and are typically safer as a result.

Another key difference between these two types of funds is their availability. Hedge funds are only available to a specific group of sophisticated investors with high net worth